Designing Objects for Flash


Now you know, technically, how to create your own custom prototype objects in ActionScript. What you might not know, especially if ActionScript is your first foray into the world of OOP, is how to design your objects.

There are literally dozens of books on object design. In fact, good object design is seen less as a science and more as an art. However, there are a few basic principles that you should to stick to.

First of all, make sure that your object encapsulates a single abstract idea. This keeps your object focused and gives the code a better chance of reuse because the object isn't overly specialized.

When you are designing the methods (the code that makes the object do something) for an object, try to keep it so that you almost never have to directly manipulate a property of the object. Instead, design functions to manipulate internal variables as needed.

Finally, try to keep the actual usage of an object as simple as possible. The object itself can have horribly complex code inside it, but that should be transparent to the end user . The real art of coding is when you can make something complex appear to be simple.



Inside Flash
Inside Flash MX (2nd Edition) (Inside (New Riders))
ISBN: 0735712549
EAN: 2147483647
Year: 2005
Pages: 257
Authors: Jody Keating

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net