Long, descriptive names

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...


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
Site Admin
Posts: 120
Joined: 19 Feb 2013, 20:33

IF you want to ((lose weight) OR (have unbelievable (brain function AND mental clarity))) THEN click:

free counters

eXTReMe Tracker