Skip to content

Clean that code!

A comment in some source code:

1
2
// When I wrote this, only God and I understood what I was doing
// Now, God only knows

A famous quote by Karl Weierstrass, the mathematician who gave us epsilon and delta continuity definition.

Just think of this comment for a second and let’s just be honest with ourselves. I believe that we all wrote code like this. Code that is not quite clear, code that is not expressive enough – in one word – a terrible code.

Imagine if someone else looks at our code.

Let’s see what it looks like:

1
2
// somedev1 -  6/7/02 Adding temporary tracking of Login screen
// somedev2 -  5/22/07 Temporary my ass

You can find more funny comments at Stack Overflow.

So, can we then define, what the valid measurement of good code quality is?

Valid Code Image

πŸ˜€

Is there any way, or someone, who can teach us how to write better code? Sure.

I would recommend a book: Clean Code: A Handbook of Agile Software Craftsmanship by Robert C. Martin. It’s a very good start. Buy it.

If I were to describe this book in one word, I would pick – brilliant. Actually it’s more like The Book of Genesis for the Software Engineers.

Let’s have a look at couple of quotes from the book:

About Clean Code:

Clean code is simple and direct. Clean code reads like well-written prose. Clean code never obscures the designer’s intent but rather is full of crisp abstractions and straightforward lines of control. Writing clean code is what you must do in order to call yourself a professional.

― Robert C. Martin, Clean Code: A Handbook of Agile Software Craftsmanship

About naming our variables in code:

You should name a variable using the same care with which you name a first-born child.

― Robert C. Martin, Clean Code: A Handbook of Agile Software Craftsmanship

About bad code and refactoring:

Of course bad code can be cleaned up. But it’s very expensive.

― Robert C. Martin, Clean Code: A Handbook of Agile Software Craftsmanship

I will stop here. This guy is simply amazing!

Find this book. Read it. Become better. Have a nice day!

Published inBooks

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: