This post is a continuation of Metrics on quality of software
As developers we like our solutions cut and dried. For every problem there is a tempting desire to believe that there exists one perfect solution if only we look hard enough.
Yet we have already talked about the futility of such a belief. The tl;dr version is that you only fully understand your project once the code committed, not a moment before.
This may not be a problem if a single optimal design existed, but the reality is that the design space is exceedingly rich. Wether you chose to believe it or not, there is almost certainly a better design than what you just committed.
With this in mind then the goal is not to find an optimal solution but to evaluate trade offs for what best serves your purpose. To that end I present a Metrics on quality of design.
All good things come from the heart, and as we all know managing complexity is at The heart of software engineering
From the lofty heights of this generalities you may be wondering how do you measure complexity in software. Well there are a myriad of standard software metrics but almost all of them require the project to be done before you can apply them. I think the most intuitive is to simply ask yourself.
Does this design allow the developer to concentrate only on this part without knowing any other part of the project?
Make a habit of asking yourself this question regularly as you are spitting out the code.
You can talk about speed or maybe even Big Omega but as far as I know, none of this ideas owns a shotgun. Do you know who owns a shotgun? The developer who is going to maintain your code, and yes they know where you live!
In your design always assume that the next developer to touch the code lacks any contextual knowledge. As such the design should be well documented and even better, be rich in the quality of affordance.
As a rule of thumb remember
It is easier to make changes in your code during development than it is during maintainance.
Software reuse is a very old and a very successful idea.
We routinely reuse various software components in writing our code, math function, string manipulations etc.
Yet it’s a rare breed that writes their own software in a way that can be reused! Be the change we all want to see.
Remember back when we talked about trade offs? Well here we have one in practise. To reuse code means to increase the dependency between your code and the code you are reusing. Yet this is a necessary part of advancing your software.
When we don't control the dependencies in our code, the second law of thermodynamics comes into effect in its full glory.
As with all necessary evils, we need to keep dependencies to a minimum and for large projects, a clear interface should be defined and the dependency fulfilled at compilation.
Check this awesome article by Martin Fowler for more context InversionOfControl
Have you ever made a change to the mapping area of your application and have the login area explode? This has happened to one of my colleagues and needless to say, the entire code base had to be scrapped!
Changes to your code need not be catastrophic, in fact with a little forethought your design should be able to handle such changes gracefully.
Welcome changing requirements, even late in development. Agile processes harness change for the customer's competitive advantage. ~Agile manifesto
To do this make sure areas most likely to change are properly insulated and interfaces defined.
The wisdom of life consists in the elimination of non-essentials ~Lin Yutang
Mr Lin would have made for an excellent developer!
Most code written is simply fluff, this wouldn’t be a problem except for the fact that the extra code adds very little value yet manifests its full weight in maintenance costs. The single most effective way of dealing with it is to cut it out.
Whenever standardization is mentioned, developers get belligerent perhaps under the assumption that they are being treated as interchangeable cogs.
But the truth is, standards confer leverage, by using standard tools and practises to mill through the mundane bits, you free up the energy to exercise creativity on what is truly important in your project.
Have you come across a good design lately? Do you feel that the developer took into consideration the principles mentioned above? Tell us what you think in the comment section below.