Stop writing legacy Code – What’s Clean Code

Clean and dirty

If you want to stop writing legacy code we have seen the importance of doing TDD, because it let’s you refactor your code and improve it. Well, actually refactoring lets you change your code, modify it. To actually improve it you need to change it in a positive way, with a better structure. You need to know how to improve it. That’s why in the following blog posts will talk about some guidelines to clean our code.

The father of Clean Code is Robert C. Martin (or Uncle Bob), he has written a number of great books that I suggest you read. A great deal of what will talk about comes straight from the book Clean Code: A Handbook of Agile Software Craftsmanship that in my opinion is the bible  in this matter. Another important book is Code Complete: A Practical Handbook of Software Construction by Steve McConnell.

We will first have a look at names and how to choose them in a way guides us through the code, than we’ll talk about functions how big (or small) they should be, then how to (not) write comments and some guidelines for your classes. Finally after we have clean production code we will explore the importance of having also clean test.

But what does it mean to write Clean Code. It means writing code that is easy to reason about. When you first approach it, or when you navigate in it you should feel like you know it. The names should guide you, and every function should turn up to be pretty much what you expected.

Working on clean code is a great experience and since you are the one writing code… why not write it clean?


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s