• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Variable names
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Variable names


  • Subject: Re: Variable names
  • From: BareFeetWare <email@hidden>
  • Date: Wed, 12 Jan 2011 15:27:27 +1100

On 12/01/2011, at 2:22 PM, Stockly, Ed wrote:

> Below is a work in progress from a few years ago.

> Please feel free to comment, critique or offer suggestions.

OK, will do.

> Variable Labels
>
> Variable labels should be descriptive of their contents.

Absolutely :-)

> Variables labels may be compound nouns that consist of two or more words merged into a single word, with capitalization marking the beginning of the second and subsequent words. The first letter of variable labels should be lowercase (to distinguish from handlers)

> Variable labels examples:
>
> userDocument
> thisItem
> myPage
> fileInUse

Yes, I use the same style, but I guess the style is arbitrary as long as the actual name is descriptive.

> Single Character Variable Names
>
> The exception to the previous rule is counters which serve no other function except as an index within a loop.

I disagree. I see no reason why loop counters shouldn't also be descriptive. In fact, I especially find it useful within nested loops to know exactly what each loop is counting, by looking at the name of the counter. Instead of i, j, k etc, why not describe the actual thing being counted, with names such as rowNumber, columnNumber, fileNumber, paragraphNumber etc (or use N instead of Number, eg rowN, columnN, fileN, paragraphN)?

> If using a single character variable label for integers adds any confusion a more descriptive term should be used.

I would take that further and say that not using a more descriptive term inherently omits information. While not necessarily "adding confusion" it makes it harder to understand for no good reason.

Thanks,
Tom
BareFeetWare

 --
Comparison of SQLite GUI tools:
http://www.barefeetware.com/sqlite/compare/?ml

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Re: Variable names (From: "Stockly, Ed" <email@hidden>)

  • Prev by Date: Re: How to do a goto with Applescript?
  • Next by Date: Re: Variable names (was: How to do a goto with Applescript?)
  • Previous by thread: Re: Variable names
  • Next by thread: Re: Variable names
  • Index(es):
    • Date
    • Thread