We shared earlier this week about a presentation some of our consultants made to the company explaining what unit testing is, and how, correctly implemented, it can translate to better custom software and code that is extensible, maintainable and scalable. I wanted to take a moment and take a closer look at one concept discussed during the presentation, code smell.
As a creative marketing-type, the term makes me giggle just a bit, as I imagine the smell of rotten eggs wafting from my computer. Of course, this isn’t what code smell means at all. In fact, the average computer user would never even be aware that anything is wrong.
So what is it then? Code smell gives developers an indication something may be wrong with a piece of software.
Code works best when it is simple. When the design becomes overly complicated, any changes will cause the system as a whole to break down. Code smell generally manifests itself in a number of ways. Examples include:
- Code duplication
The best practice here would be to reference a piece of code that a programmer wants to duplicate, rather than copy and paste.
- Class functions that do too much
A good practice is to create classes and functions that do one thing and do it well; this will lead to a more modular code base.
- Code isn’t readable
As a rule, good code reads like a book. If it doesn’t, the design is probably not laid out in a thoughtful way.
- Code depends on concreteness
Best practices for creating code indicates that it should be abstract. This allows different “parts” to be interchangeable where necessary.
Depending on your background, these issues may or may not mean a whole lot to you. And as you utilize a software application on a daily basis, most of these code smells won’t actually effect your ability to get your job done.
But if your internal team of developers tries to perform routine maintenance, fix bugs or add features, there is a high likelihood things will begin to go wrong. Over time, bad code design results user frustration, more time spent programming, and therefore higher cost.
Don’t let a software application vital to your business get to the point of being so tangled up in its own code that no one can use it anymore.
Sign up for a software audit today, and get the information you need to make informed decisions about your valuable asset.