Monday 18 May 2015

Can You Smell That?


As developers over time we learn a broad range of skills, we learn to become technicians and actually produce the code, we learn to become architects and structure the solution and we also develop a sense of smell.
This sense of smell is the invaluable intangible quality of an experienced developer, the ability to know when something just doesn't look right.
Trust Your Instincts
Quite often you won't be able to articulate exactly what is making you feel uncomfortable about a particular piece of code or design but trust yourself, you know what good and bad code looks like.
Its important to bottom out what you think the smell is, its much better to take an hour now then to ignore what your experience is telling you and store up trouble further down the line.
Using Some Air Freshener
Talking it over with someone else in your team will force you to try and put into words what you think the problem is.
Try to work out if your issue with the code is related to the design or the implementation, is it related to performance or maintainability, gradually home in whats bugging you.
Is this API just wrong or do I just not like this switch statement? 
Am I worried about how this scales or do I just think we should split this function up a bit?
A lot of problems in development have been encountered before, some research online might well turn up other peoples thoughts on similar issues and how they went about solving them.
If you think its related to the structure of the code a quick review of standard design patterns might bring the light bulb moment, thats the problem we've got!
I've Smelt This Before
The complete list of all code smells is probably endless but there are certain standard smells that you should get used to the stench of, things like,
  • This code would be really difficult to change in the future.
  • This code is really difficult to test.
  • Its difficult to explain to others how this works.
  • This part of the code is always breaking. 
  • We seem to copy and paste this a lot.
Its important to distinguish these smells from personal preference, just because you wouldn't have coded that way doesn't mean its wrong, but if your nose starts twitching just take the time to work out where that smell is coming from.
A good sense of smell is what distinguishes good developers from mediocre ones, always trust your instincts there what makes you one of the good ones, don't just settle for something that works take a deep breath and smell the roses.  

No comments:

Post a Comment