Thursday, 13 June 2013

Be brave! Delete code!

Most developers have fear of changing code that they don't know. Adding new code is OK for everyone - even in large functions or large classes. That of course leads to mess in code and big ball of mud syndrome.

The main problem is that only a small fraction of developers actively try to understand what others have written before. Is this lazines? Or lack of confidence? Or maybe deadlines are tight and writing new features is more important that code refactoring or fixing bugs?

My advice is: don't be one of these guys. Don't do just what is assigned to you. Spend a little bit of time looking around for possible improvements. If you see a big method - split it. If some flow is hard to understand - improve it. If naming is bad - change it. And one of most important things - be brave and delete dead code. If it will be needed again (it probably won't) - you have source control systems (if not - change company).

Now imagine if everybody in your team have spend some time every week on improving exiting code, from beginning of project. I know it is a bit of investment of time for the project/company, but remember: changing clean code is much easier that changing big ball of mud. It will pay off.

No comments:

Post a Comment