Don’t get clever.

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.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: