Wednesday, November 22, 2017

Pick the correct name

Picking up a correct name for the software component is one of the hardest things that every developer has to deal with. Here I refer component as anything in your source code, it can be a variable name, function name, class name or anything. Having a perfect name for the component is a huge achievement it improves the readability of your code so let's find out some of the qualities of a good name.



This is a swarm, in Sinhalese we called this animal as "thisara" which means it can live in water, air or land or can live in all three spaces. What a perfect way to define the behavior of an object by its name.





Let's list down some of the core qualities a name should have.

  • Readability.
  • Pronounceability.
  • Representing one context.
  • Do not use acronyms.
  • Follow two points are taken from a tweet of Robert C Martine ( AKA uncle bob )
  • The length of a variable name should be proportional to its scope. The length of a function or class name is the inverse.