One way to transform code into more maintainable code is to separate concerns into different modules. There is usually a question of when this should be done and how to do it. I use testability as one determining factor of how to perform the separation. Let’s start with an example:
Here’s code from some production code that has been de-identified. The method receives a response from a service and performs logging, throwing an exception, or both.