In my last post, you learned what the Single Responsibility Principle is, why it is important, and its benefits. You’re now able to apply SRP at the class level.
Today, I’ll show you how to apply SRP at the method level.
By looking at some practical examples, you’ll learn how to spot potential code smells so that you can refactor your methods into shorter methods. You’ll write shorter methods with each doing just one thing. This’ll make it much easier to write unit tests because the inputs and outputs become obvious. There are also fewer edge cases per method.