Essay 31 Know When to Refactor

Another smell of complexity arises when we think too far ahead in our code. There’s a price to pay for being too cute or too cerebral about the actual thing we’re trying to build. A classic case is implementing a design pattern too early.

Don’t get me wrong, design patterns are wonderful things. When a common programming approach happens over and over again, we get excited. We’ve all experienced that sense that our code could be doing something greater than just solving the concrete task at hand.

When we’ve had this feeling a few times and successfully refactored our code into more abstract patterns, it’s easy to feel invincible. We work like a crime dog, sniffing out any small sign or clue, any hint, that ...

Get The Developer's 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.