Pushing complexity down to lower levels is a common refactoring. We'll TDD a small class to work on, then look at two ways to push a particular conditional down to a lower level. One of them will result in a much better design than the other. This shows that merely pushing down isn't enough; sometimes it's simply redrawing the lines in the same bad design.

Execute Program

Looking for something more interactive? Try Execute Program, an interactive learning platform from Destroy All Software LLC! It has courses on TypeScript, SQL, regular expressions, JavaScript concurrency, and more. All Destroy All Software subscriptions include full access to Execute Program, or you can subscribe to Execute Program directly.