• 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: loops [naming variables]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: loops [naming variables]


  • Subject: Re: loops [naming variables]
  • From: has <email@hidden>
  • Date: Sat, 16 Feb 2002 01:56:33 +0000

Arthur J Knapp wrote:

>> though i'm sure i've done it myself, it's really poor
>> practice to litter teaching examples with meaningless
>> variable names, especially in a supposedly
>> "self-explanatory" language like AppleScript.
>
> I'm afraid that I cannot agree with that, (at least not in all
>situations). Look, if you're learning a language for the first
>time, obviously you need a lot of help with figuring out what is
>what, but once you've developed even a little bit, long and
>descriptive variable names can actually get in the way of
>quickly understanding a simple algorithm.

Whereas non-descriptive variable names can get in the way of understanding
the Big Picture. The knife cuts both ways...:)


> Now a days, when I read something like:
>
> repeat with an_incrementing_variable from initial_value to ...

Examples of bad common naming practices please step forward.:)

Me, I'm really bad for stuff like:

repeat with eachItem in theList

Which is barely one step up from 'i' and 'x' in the informative stakes. [1]
(What's in an item? What's the purpose of the list?) What you really want
are variable names like:

repeat with anEmployee in employeeList

or:

repeat with eachVegetable in the vegetableBasket

Both of which provide genuinely useful information about what these
variables are used for. Whereas names like 'theString' or
'incrementing_value' don't tell you anything that you don't already know,
or can't work out from a few seconds grokking the code. Think semantics.
And consistency.

Cheers,

has

[1] Which is not to say that 'i' and 'x' and 'theString' never have their
places, but should probably be used sparingly in circumstances where their
terseness doesn't hinder meaning.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: loops [naming variables]
      • From: Emmanuel <email@hidden>
  • Prev by Date: Re: "on run" & "on re-run"
  • Next by Date: smi-file to launch an app to open the volume
  • Previous by thread: Re: display dialog and screen saver bug?
  • Next by thread: Re: loops [naming variables]
  • Index(es):
    • Date
    • Thread