Clean Code Chapter 1&2: Clean Code & Meaningful names

I have started reading the book Clean Code by Robert C. Martin, which is considered to be a industry standard for writing maintainable and elegant code.

Because this book is such a heavy read, and each chapter is full of content and a knowledge bank in itself, for personal reference I’ve decided to summarise each chapter in a set of blog posts.

Chapter 1 : Clean Code

This was more like chapter 0. Author describes what is clean code and cost of maintaining it. How clean code is directly related to team productivity and what makes clean code clean.

It contains views on clean code by many of industries best known people like Bjarne Stroustrup, Michael Feathers etc.

One of my favourite definitions form the book covers it best :


Chapter 2 : Meaningful Names

Names are everywhere in software. We name our variables, our functions, our arguments, classes, and packages. Because we do it so much, we should do it well.

1. Use intention revealing names : 

The name of a variable, function, or class, should answer all the big questions. It should tell you why it exists, what it does, and how it is used.

int d; // time elapsed

Here d reveals nothing. A better name would be

int timeElapsedSinceCreation;

2. Avoid Disinformation :
Programmers must avoid leaving false clues that obscure the meaning of code. We should avoid words whose entrenched meanings vary from our intended meaning.

int accountsList;

Should only be named so if it is a actually a list data structure that’s used to store the accounts. Not an array or set.

3. Make meaningful distinctions
Entities named different, should be different, mean different.

If we have classes called




, you have made the names different without making them mean anything different. Info and Data are indistinct noise that doesn’t differentiates what they actually mean.

4. Use pronounceable names

Makes communicating about the code easy.

long genydhms;

is not a good name.

long generationTimestamp;

is a better choice

5. Use searchable names
Avoid single letter variables and constants as they are difficult to search.

6. Avoid Encodings

Hungarian notations, member prefixes, interface and implementations should be avoided.

It just adds another burden to remember the encoding format being used.

7. Avoid mental mappings
Readers shouldn’t have to mentally translate your names into other names they already know.

int r;



is lower cased url with host name removed adds to much requires too much mental juggling and mapping when working with the code.

A better name would be,

int urlWithoutHostName;

8. Class Names
Avoid words like Manager, Processor, Data, or Info in the of a class. A class name should not be a verb.

9. Method Names
Methods should have verb or verb phrase names like postPayment, deletePage, or save.

10. Don’t be cute

If names are too clever, they will be memorable only to people who share the
author’s sense of humor, and only as long as these people remember the joke.

Don’t tell little culture-dependent jokes like eatMyShorts() to mean abort().

11. Pick one work per concept
Pick one word for one abstract concept and stick with it.

It’s confusing to have a controller and a manager and a driver in the same
code base. What is the essential difference between a DeviceManager and a ProtocolController?

11. Use solution domain names
It’s OK and preferable to use names from computer science and programming domains.
In transctionObserver

the word observer means a great deal to person who knows the observer pattern.

12. Use problem domain name
The code that has more to do with problem domain concepts should have names drawn from the problem domain.

int mriRecord

In a healthcare app will give a great deal of context than just

int record


13. Add meaningful context
Enclose names in well named functions, classes, namespaces, etc.

String state;

In a class called FiniteStateMachine will mean different that in a class called Address.

14. Don’t Add Gratuitous Context
In an imaginary application called “Gas Station Deluxe,” it is a bad idea to prefix every class with GSD.
Frankly, you are working against your tools. You type G and press the completion
key and are rewarded with a mile-long list of every class in the system. Is that
wise? Why make it hard for the IDE to help you?


This was part one of a 16 part series on the book Clean Code by Robert C. Martin, where each post covers a gist of a single chapter.



Mastery By Robert Greene : Reading Experience



Mastery is a book that takes a deep dive into the so-called “superpowers” of masters in various fields and connects it directly to the pillars of mastery like grit, dedication, patience, creativity and intuition.

It contains life studies of legends like Vinci, Darwin, Faraday etc to contemporary legends like Carlo Rodriguez, Santiago Calatrava, Paul Graham etc. And time, again and again, it stands upon elusive pillars like grit, creativity, patience, etc which drives one towards mastery, not just god gifted super powers.

The book condemns that people are not willing to do what it really takes to become masters in their fields and label it as something that can be only achieved by born geniuses.

It starts with covering the importance of the apprenticeship phase. The phase that constitutes the beginning of everyone’s career, even of true masters like Faraday, who did the apprenticeship  at a scientist’s lab for 7 years before going on his own to make history.

During the apprenticeship,  one should focus immensely on learning the vocabulary of the field in depth with patience. Then experiment with his/her own tastes.

Next, comes the creative active phase, where after learning the tools of the trade and becoming proficient in important skills, masters experiment. They mix and match things, blend various fields and concepts and bubble up ideas.

The book presents various strategies for the creative active phase like:

  1. The Authentic voice: Learn the vocabulary of the field first.
  2.  The Fact of Great Yield: Look for anomalies with profound ramifications.
  3. Mechanical Intelligence: Key to building anything right is repetition.
  4. Natural Powers: Enjoy the laborious process.
  5. The Open Field : Create space for yourself in crowded space.
  6. The Evolutionary Hijack: Creativity and adaptability are inseparable.
  7. The Dimensional Thinking: Feel the breathing element in your field.

My favorite quote from this segment of the book was:

Languages evolve in haphazard manner, influenced by the influx of new groups into a society and stages by passage of time. They are not mathematical formulas but living, evolving organism.

Next, the author puts the spotlight on the vitality of “the ultimate reality“. Life is interconnected and it all started with a single cell two billion years ago.

Mastering a field can not be done in isolation with other things. Any field that we are working on, it has been shaped by events, minds that have worked on it and time. It is simply not right to build artificial walls around subjects and study them in isolation.

Strategies suggested in the book to get the rational intuitive feel:

  1.  Connect to Your Environment: Become a consummate observer.
  2. Play to Your Strengths: Have a supreme focus on your strengths.
  3. Transform Yourself Through Practice: Get the fingertip feel.
  4. Internalize the Details: Have the patience to give attention to even the most minute details
  5. Widen Your Vision: Get the global perspective.
  6. Submit to the Other: Loose the sense of superiority when learning from someone.
  7. Synthesize all forms of knowledge

My favorite quote from this part was:

Things push and pull into each other and breathe together, and are one.

To conclude, Mastery is a great book to help people shape their mind in a way that knows what to expect and what it takes to travel on the path of mastery. And that mastery is not a destination but a lifelong journey. One should maintain a beginners mind as they grow old like zen masters.

When you read a great book at the right time, it can only go in the category of Supremely Fucking Awesome.





Zen and the Art of Motorcycle Maintenance : Reading Experience

The Japanese motorcycle maintenance guide says “ Assembly of Japanese bicycle requires great piece of mind”. There is a thing about everything you build, including bikes. If you build it with non-serene mind, then you build your problems into it.

The book takes you on a cross country bike journey that will teach you mind opening lessons that leave lasting impressions on your mind. Your mind will simple refuse to contract itself to older stage.

One of the most important lesson that book teaches you is to enjoy the common little things that life has for you. There is as much Buddha in cogs of bike, as there is at the top of the mountain.

Towards the beginning of the book the author says, “If you want to set out for the most amazing bike journey, you have learn the art of motorcycle maintenance.” The quote has so many meanings at different levels that your mind can explore the words in infinite ways.

As the bike journey progresses, author makes the point that the key to be doing great work is to be completely involved in it. Not like mechanics who listen music while working on the bike with no intention to make it great, the noise of the tools should be music.

How we see the world affects how we think about it. There are two ways to see the world, the classical way where everything is logical and the other is the romantic way.

Classical way of thinking runs the knife on views, something is cut. And when the logic in the logic is found, the beauty of the unknown is lost.

Romantic way of thinking is all about enjoying the continuum of things.

Quality is the thing that author says that you know what it is, but still you can not define it. Like you know what makes a tomato soup good, but yet you can not define what makes up its quality, both materialistic and spiritual.

World consists of three things : Mind, Matter and Quality.

The author was a student of University of California at one point, before his nervous breakdown. Studying there he made some amazing point on the thinking of Plato and Aristotle. How dialectic way of thinking is different from rhetoric way of thinking, but at the same time one doesn’t proves the other wrong.

My two the favorite quotes from the book are :

  1. “The only zen you’ll find at the top of the mountain, is the zen you take with you”.
  2. “The test of the machine is the satisfaction it gives you. There isn’t any other test. If the machine produces tranquillity it’s right. If it disturbs you it’s wrong until either the machine or your mind is changed.”

This is the best book that I have ever read. No matter what you are doing in your life and how old are you, this books touches your mind at levels so deep that you didn’t even think it was possible. But you’ll have to keep the beginner’s mind to learn.

As the author states, “sometimes it is better to travel than to arrive”. I was carried away with the philosophical ideas presented in the book and the serenity that the country side description provides.

Knowing that Chris, the son of the author, with whom he set out for this bike journey is dead was a little sad. But again in snap that increases the importance of all the lesson and the author was expounding throughout the book about life and zen.

A recommended read for everyone.

The next book that I have picked is “The Blue Ocean Strategy”.