Clean Code: Meaningful Names

I recently started reading "Clean Code" by Robert C. Martin. This is a very short summary about the first Chapter: Meaningful Names.

September 6, 2017

For a while now, I was planning to read “Clean Code” by Robert C. Martin, a must-read book for a developer. The knowledge and experience over decades collected in this book is priceless for me. The first couple of pages already hit me.

There are a lot of tips and best-practices to follow. I summarized them – mainly for me, but maybe still useful – on a github repository, which I am going to extend with the further chapters. I also included some easy and short examples – mainly copied from the book, slightly adapted – to illustrate some of the topics. The repository can be found here:

 

For this post, I am using quotes from the book, which are the essential messages of the first chapter “Meaningful Names”. I think they summarize the intentions behind the chapter.

 

“The Problem is not the simplicity of the code but the implicity of the code”

The first quote is on the first part of the chapter with a small but very clear example what it means. Naming is not only to have variables and different functions or classes, it’s about information and intention. Therefore, name with awareness, caution and let your code talk.

 

“If names must be different, then they should also mean something different.”

The quote is from the part “Make Meaningful Distinctions” which describes how names can lead to noninformative constructs. Typical mistakes – or laziness – like arbitary variations of variable names, adding unnecessary noise words or mixing word concepts reduce the quality of your code.

 

“One difference between a smart and a professional programmer is that the professional understands that clarity is king”

Let me repeat: Clarity is king. And without further explanation, I am just gonna copy&paste a sentence from the book:

“After all, if you can reliably remember that r is the lower-cased version of the url with the host and scheme removed, then you must clearly be very smart.”

 

“Say what you mean. Mean what you say.”

If you work in a professional environment, and by that I mean, where you create client or user software or applications, be precise and clear with your code. Don’t use funny or culture-depentend names for functions or classes. Remember, you are not the last person who will see and work with your code base.

 

I am well aware that this post is rather a shallow summary about the first chapter “Meaningful Names”, but I hope I could get you some idea what it is about. Also check my github-repository for some more insights, but don’t expect an academic summary of the book 🙂