I'm not saying I haven't (or don't continue to) use if (!this.length),
but false is not the same as 0, nor is it the same as null or undefined
and they are important distinctions to make.  It's true that all of
those return true for not, but in more strictly typed languages this can
be problematic.

If you do a check for this.length == 0, you are eliminating the
possibility of a true result for undefined (or null), which is what
would happen if you pass an object where an array or string is intended.
If you can't strict type the argument because it needs to accept either
a String OR an Array, it means you have to strict type it using Object
(which in Flash means typing it is pointless, since everything is an
Object).  Doing so means you can return true for (!this.length) with an
object, even if your code after thinks it has an empty array or string.
And what if your object has a length property?  Yikes.

The reason it's sloppy is because debugging it can become painful later
on when it's buried in thousands of lines of code.  If your code is
tighter and stricter and you don't take shortcuts that Flash lets you
take due to its loosely typed language, you're more likely to write
better code because you're disciplined to do so, and debugging will go
much more easily.  Also, if new players become more strict, old
shortcuts like (!this.length) may break.

Flash programmers can develop "bad habits" as a result of Flash's
loosely based typing.  I'm just saying it's not a bad thing to reel it
in and save yourself from potential debugging issues down the road, and
make it easier if you ever intend on learning a lower level language.
:)


BLITZ | Steven Sacks - 310-551-0200 x209

_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to