
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Type Syntax
|
31
As noted earlier, static typing is not universally accepted as the best way to imple-
ment type checking. The jury is split, but many well-known programmers argue in
favor of dynamic typing over static typing. Dynamic type checking is often less
restrictive and can make code easier to change than statically typed code. Those
arguments aside, ActionScript 2.0 will be statically typed for the foreseeable future
because static typing is part of the ECMAScript 4 specification on which Action-
Script 2.0 is based. However, if type theory debates titillate you, you should enjoy
these articles:
• Static Type Checking, by Dave Harris, at http://ootips.org/static-typing.html
• Strong Typing vs. Strong Testing, by Bruce Eckel, at http://mindview.net/WebLog/
log-0025
The main advantage of static type checking is that it can check all your code at com-
pile time, whereas dynamic type checking requires that you execute the code in order
to verify it. To be sure that all your code is executed, you need to perform unit testing
on each module (writing classes specifically to test the output of other classes). Mr.
Eckel argues that combining religious unit testing with dynamic type checking offers
all the error-catching benefits of strong typing and more. For a quick-and-dirty
example