Program by Intention

If I have a public API, a method, or some service I’m providing that I’m exposing to the outside world, I won’t put any implementation in that method. I will simply delegate to other methods.

I do that because it makes the code easier to read. If you delegate some code, and then do some of the implementation, you’re switching perspectives, dealing with things on the conceptual level at times and at the implementation level at other times. When you do that, you may find there’s a little task switch that flips in your head. It’s not much but when you do it over and over and over again, it becomes very taxing.

Remove that repetitive effort by simply delegating all bits of functionality to separate methods in all your public ...

Get Beyond Legacy Code now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.