Guru and Nubie

Renil’s Blog

Archive for the ‘Uncategorized’ Category

Short vs. Long variable names

without comments

For a long time, I haven’t written any post. I was a looking for a good topic. Now I came across a post by Isaac Schlueter in “YCombinator”. So thought of sharing it.

There’s a lot of “short vs long” going on in the comments here. That seems silly to me.Code should be written so as to completely describe the program’s functionality to human readers, and only incidentally to be interpreted by computers. We have a hard time remembering short names for a long time, and we have a hard time looking at long names over and over again in a row. Additionally, short names carry a higher likelihood of collisions (since the search space is smaller), but are easier to “hold onto” for short periods of reading.

Thus, our conventions for naming things should take into consideration the limitations of the human brain. The length of a variable’s name should be proportional to the distance between its definition and its use, and inversely proportional to its frequency of use.

Global config setting that gets specified once and used in 4 places throughout the program? 10-20 characters is probably appropriate. Might wanna go with UPPER_SNAKE_CASE to make it stand out a bit more, even.

Iterator variable that you define in a 3-line for loop and then never see again outside of it? Call it “i”.

Another way to look at this: The first time you meet someone, you learn their full name. When discussing them with someone else who knows them, you use just a single name. If they’re standing right there, you don’t bother using their name, but just make eye contact, and maybe a “Hey”. Should be the same way with variables.

Read the full post and reader comments in “http://news.ycombinator.com/item?id=840331

Happy Reading!!

Written by renil

September 27, 2009 at 4:38 pm

Posted in Uncategorized

Back again after a year

without comments

I was busy working with a Project and was not able to update the blog for around one year.

As I am returning back, I have updated the wordpress template for the site. The WordPress look and feel has been changed and I have seen a lot of changes in other sites also including Joel On Software.

Let us see how much I can write this year :)

Happy Coding…

Written by renil

January 21, 2009 at 7:23 pm

Posted in Uncategorized

Happy New Year

without comments

Happy New Year

Wishing you all a happy and prosperous New Year..

Happy Coding

Written by renil

December 31, 2007 at 3:02 pm

Posted in Uncategorized

Visual Ergonomics in the Office

without comments

We are all discussing developer productivity and efficiency. But we should also have some consideration towards developer’s health.

Visual Ergonomics in the Office is a good article to read as we are all depends heavily on our eyes.

Written by renil

November 7, 2006 at 2:40 pm

Posted in Uncategorized

What makes them Gurus?

without comments

Nubie: Have you ever thought of this in your life?

Guru:

When people see things as beautiful,
ugliness is created.
When people see things as good,
evil is created.

Being and non-being produce each other.
Difficult and easy complement each other.
Long and short define each other.
High and low oppose each other.
Fore and aft follow each other.

Therefore the Master
can act without doing anything
and teach without saying a word.
Things come her way and she does not stop them;
things leave and she lets them go.
She has without possessing,
and acts without any expectations.
When her work is done, she take no credit.
That is why it will last forever.
–(Guru: Lao-Tzu in Tao Te Ching )

Written by renil

September 15, 2006 at 3:00 pm

Posted in Uncategorized