Don’t Get Clever

Sean Coates
Aug 23, 2017 · 2 min read

Don’t write complex software just because the technique looks cool.


From time to time new techniques will appear on the web, and then everyone will start over-using them for anything and everything. A couple years ago it was the repository pattern. This pattern has its uses, but when working with a framework that already has Active Record in it, it often gets abused. Next thing you know people are creating an in-house active record on top of a repository on top of a real active record on top of the data access layer. Needless complexity.

This is especially true for simple models where using the framework’s Active Record alone is all that is really needed.

Another example is where a very intelligent programmer will invent some clever algorithm that saves several lines of code or shaves a few milliseconds off the compute time. It’s valid, it passes tests. It does what it is supposed to do. The problem is that when other developers revisit the code later, they can’t make heads or tails of it. As a result, to add new functionality, they sometimes have to replace the whole class. Or worse, the clever algorithm is spread across several classes like a cancer, making it extra hard to replace or extend.

Software engineering does take a significant amount of intelligence. Don’t treat it like a contest to see who can create the most obscure code. Software that is more easily improved and extended in the future has much more value.

So don’t get clever with your code. It will confuse the future people who have to support it.

)

Occasional posts from @fooyay about software engineering, crypto, finance, and more. https://about.me/fooyay (Content reflects my opinion and not my employer.)

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade