Re: Global variables
Re: Global variables
- Subject: Re: Global variables
- From: has <email@hidden>
- Date: Sat, 10 Mar 2007 18:02:44 +0000
Ed Stockly wrote:
>>>All I'm trying to do is create a droplet that starts out by
declaring and initializing a bunch of global variables, then runs a
series of subroutine calls to do the work.
Very good, sensible approach. (although some "old school"
programmers will argue that it's more efficient to use local
variables passed to handlers rather than globals, but feel free to
ignore them)
No, old (and new) school programmers would point out that overuse of
globals is bad design that makes code harder to test, change,
understand, etc. (e.g. See <http://en.wikipedia.org/wiki/
Global_variable> for a rough summary, Google for "spaghetti code",
and/or get yourself a copy of Code Complete if you want to learn more.)
I agree with the others who responded about Globals vs. Properties.
It has been my experience that properties work better, are easier
to grok and are more reliable than globals, particularly in droplets.
Ditto. (Although I wouldn't say globals are inherently "unreliable" -
it's just that there's fewer ways to confuse yourself/accidentally
muck things up if you stick to using locals and properties, and avoid
globals.) Properties are cleaner and easier to understand, and
effectively serve the same purpose anyway [1].
has
[1] While there are some differences between their scoping rules,
these only become noticable in badly written code - i.e. just one
more reason why globals are best avoided in the first place.
--
http://appscript.sourceforge.net
http://rb-appscript.rubyforge.org
http://appscript.sourceforge.net/objc-appscript.html
_______________________________________________
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