Function Keys

So you’ve been using Clean Swift for your apps and are reaping the benefits. Now it’s time to go beyond the VIP cycle. What about the workers and custom subviews? They fall outside the VIP cycle, but are still part of your app. So they need to be properly designed.

Or, you may have an existing app that is too invested in MVC or MVVM. And you’re faced with massive view controllers or view models. But you’re not ready to switch the entire app to Clean Swift. I’ve got some good news for you.

You can still apply the SOLID principles of software design to your code regardless of your architecture choices. Clean Swift has these built in, so you can focus on your features. But if you aren’t using Clean Swift, you just need to apply them manually to your classes and functions.

This book, Function Keys, describes the four essential keys to unlock the secret of software design. The four keys are:

  1. A function name should tell a story
  2. A function should be easy to read and understand
  3. A function should be easy to maintain
  4. A function should be easy to test

The first two keys walk you through the complete process of how to refactor complex business logic into small classes and functions. Throughout this process, you’ll learn how to recognize and break up multiple responsibilities into individual testable units (hence the term unit testing). I’ll show you how to dissect a feature to completely take it apart. And then we’ll build them back up with well designed classes and functions.

Once these are in place, here is the best part. In the third key, I’ll simulate the real world by introducing a requirement change. You’ll be forced to make changes to your code. I’ll compare both the before and after versions of the code. So you’ll understand why most developers are doing it wrong when it comes to refactoring. I’ll show you how to avoid falling into the same traps. You’ll know the exact steps to take in order to write code that is both easy to read and maintain.

All good code is tested code. Do you find it difficult to write unit tests? Or, you may do a lot of stubbing and mocking, such that in the end, you don’t even know what you’re testing. This is a sign of trying to write tests for bad code. Some developers even feel like they’re having to write and maintain two apps! The truth is, good code is always obvious to test, even trivial. The book finishes up by writing a unit test suite to fully cover every line of code in the example. I’ll show you the three phases of a unit test – Given, When, and Then. You’ll also see when you do need to stub a dependency, what functions to stub for, and the nitty gritty details of how to create a stub. This fourth key ties everything together. You’ll see why good architecture comes before testing, and testing leads to good architecture.

Function Keys is for you if you want to:

  • properly evaluate your app to find classes and functions to improve.
  • understand why your current code needs to be refactored.
  • refactor your code into small pieces of unit-testable classes and functions
  • find an architecture agnostic approach to writing good code.
  • go outside Clean Swift’s VIP cycle and design your own workers and custom views.
  • come up with good test cases to fully cover all code paths.
  • write non-fragile and maintainable unit tests.
  • make sure you’re doing the right thing before you start refactoring.
  • avoid having to refactor after refactor, again and again.

The last thing you want to do is to make your app worse than before. Low productivity hurts. But negative productivity hurts more. You can guarantee your refactoring effort will always pay off using these four function keys.

You can get Function Keys for just $49.

I use Gumroad for payment and fulfillment. It’s the preferred way of making purchases on this site, because it can instantly deliver the contents to you. However, Gumroad doesn’t support certain countries. If that’s the case for you, you can use this special link to pay. When I see your sales come through in my inbox, I will deliver the book to you.