Tuesday, May 21, 2013

Write clean code. It should be mandatory!

So I'm several months in to my latest job and into my first experience digging into other peoples code. Before this I've always been rather fortunate and created code from scratch and was able to set forth the guidelines of how it should look, etc.

This time around, I get to play with other peoples code and what I found was not pretty at all. And I don't mean pretty as in it didn't "look" nice. This code base essentially followed everything that defined "bad code". It would be a prime example of it actually. Everything from Hungarian notation, using anything but SOLID principles and useless commenting and leftover dead code scattered everywhere. And that's just the beginning. Yes, it's THAT bad. It needs major re-factoring and lots of TLC.

That being said, as a professional developer, clean code should be one of your top priorities. And just what is clean code? That in itself is a topic made for a book. Which is something that fortunately has already been written. Check out the following book and see if you can spot any of your bad habits.

Clean Code - A Handbook of Agile Software Craftsmanship

Clean code = code that's easy to follow, debug and less prone to having bugs in the first place. Make it your priority!