Scripting Style (was re: array info request)

Scott Rossi scott at tactilemedia.com
Mon Jul 25 19:07:40 EDT 2005


> Richard is right about double-click: it's the reason why I don't use
> underscores and dashes either...

If you really want to split hairs (hares?), this is a somewhat weak
argument.  If you use, for example, an underscore as a naming convention:

_myField
_myButton
_myGraphic

Or:

my_field
my_button
my_graphic

Or:

button_fred
button_jim
button_mary

...it is quite easy to select the text string you want to change/modify with
a double click -- the underscore remains unselected and doesn't need to be.
And in my case, since I don't keep track of my billable time in
milliseconds, the time it takes me to select an entire string including an
underscore is negligible. :-)

-----

And while we're talking about style and conventions (or lack of them), you
might consider using upper case letters for single character variables:

 put 25 into A

Why?  If you look at X-Talk languages in general, what is the defining
characteristic that identifies most of the reserved messages/properties:

 mouseUp
 openCard
 windowShape
 backgroundBehavior
 resumeStack

Obviously, the upper case character in the middle of each name isn't truly
*needed* for a script to function, but the capital serves as a visual cue to
identify the text string as something "reserved": a message, a property
name, etc (one could also argue the capital makes the name easier to read).

Another consideration -- assuming that at least 99 percent of developers
code in lower case, line 1 below might appear to be more ambiguous than line
2:

  put 25 into a

  put 25 into A

IMO, line 1 has the *appearance* of an incomplete script, while in line 2,
there *may* be missing script but the upper case character is a clue that
"A" was intended as a variable name.

Food for thought (and debate)...

Regards,

Scott Rossi
Creative Director
Tactile Media, Multimedia & Design
-----
E: scott at tactilemedia.com
W: http://www.tactilemedia.com




More information about the use-livecode mailing list