Bad variable names bleeds my eyes

Reading time ~2 minutes

Good-bye i,j,k … variables. Good-bye soul-less variable names. There are lot of code conventions on the web but all their focus is formatting of the program which helps avoiding bugs. There is another aspect of code convention, that is having pragmatic variable names in your program/code.

My focus is to avoid bugs in code through a sane approach of naming variables. Variable can be the common confusion point of your program, especially if you want it to be read by your colleagues and maintainers. One’s program must be like a story and variables must be the characters of the story. One definitely doesn’t want characters to have non-sense names, right? Every program must a unique story and avoid plagiarism whenever needed.


Competitive programming gave us a habit of short & funny variable names. Everyone cared about time complexity. That’s not all I never got evaluated for beauty of my program at my academia too. Code must run and produce desired effect, isn’t that the deal?


Blame game is shame, period.

More reasons, pragmatic variables makes code maintainable and doesn’t let bleed my(or others) eyes. Though it may take some time to arrive at thumb rule but it’s worth the pain. Your co-workers will really appreciate these variables, also they enhance your vocabulary(pun intended).

Thumb Rules

  • Function - [Adverb] + Verb
  • variable - [Adjective] + Noun
  • Global variables - ALL CAPS NOUN
  • Avoid borrowed/duplicate variables

So next time you go for generic names like (var_a, var_b, bad_var, i, j,…) for variables, do yourself a favor, pinch yourself or take cold showers.

Always follow good practices.

Emphasizing on writing tests

Writing test will payoff it's due in a week. Continue reading

Build your own ngrok in 4 easy steps

Published on July 28, 2018

A puzzle for you today

Published on August 25, 2017