01 July 2013

// On the Liability of Source Code

"Source Code is a liability, not an asset."

I have heard that said many times over the years but never so clearly stated, in my opinion, as in this blog post by Chris Parsons:

"Every line you write means more for someone else to read, digest and understand. Each complex ‘clever’ regular expression represents another few minutes per team member trying to interpret what you wrote and why you wrote it. Every line you add limits your project’s responsiveness to change.

Only the feature that your code provides is an asset. The more that we reduce the amount of code we write, the lighter weight and more agile our software. The easier it is to understand, the less of a intellectual drag it is on the team."

This idea is driven home more and more with every new programming challenge I aim to tackle and with every pre-existing code base I encounter. Simplicity is better than complexity. Every line of code you write becomes a line that you, and every other member of your team, have to read, test, maintain, and extend. Every statement adds complexity and is a potential point of failure.

Leveraging existing code libraries that handle tangential problems for you instead of reinventing the wheel is almost always better. They free you to focus more on the core challenges of your business which is where you want to be. Sure, sometimes the existing code libraries are meaningfully inadequate and the investment to reinvent the wheel is worth while, but those times are extremely rare. If you think you are about to undertake such a project, stop and really consider your options because you are probably wrong. Probably.

No comments:

Post a Comment