Long, descriptive names

Share this topic:



Link to this posting

Postby Ursego » 21 Feb 2013, 10:25

The common, obvious practice is to give variables and functions short names. But, sometimes, there are situations when it makes sense to break that rule and use long, "real-English" names which clearly describe what they are for.

For example, it can be done when a variable is in a rare use (like an instance var which is referenced only a couple of times), but not a local var mentioned in the code many times. Anyway, don't be afraid to give long names each time you feel it will simplify working with the code. See the difference between

Code: Select all
mainFilter = this.GetMainFilter(); // bad...

and

Code: Select all
filterBySelectedRowInSummaryScreen = this.GetFilterBySelectedRowInSummaryScreen(); // good!

As you see, names of variables can tell a whole story! Even if it makes a line too long, there is no problem to break it into two lines - it’s better than having to look on a variable with no idea what is stored in it. But remember: names of that style should be an exception, not a rule!
User avatar
Ursego
Site Admin
 
Posts: 112
Joined: 19 Feb 2013, 20:33

Return to Art of Naming

Who is online

Users browsing this forum: No registered users and 1 guest


Long, descriptive names

Share this topic:


If you think that this site is not too bad, please LIKE it in Facebook. Thanks!





cron
free counters

eXTReMe Tracker