Strategies for designing a class

The topic of object-oriented design is a complex one; entire careers have been devoted to the academic study and professional practice of this discipline. Nevertheless, here are a few suggested approaches that can help you get started.

  1. Think about the role that the instances of this class will play in the application. Generally, objects serve one of these three roles:
  2. Decide the specific functionality that the class will need. The different types of functionality often become the methods of the class.
  3. If the class is intended to serve as a value object, decide the data that the instances will include. These items are good candidates for properties.
  4. Since your class is being designed specifically for your project, what's most important is that you provide the functionality that your application needs. It might help to answer these questions for yourself:
  5. If there is an existing object that is similar to the object you need, except that it's lacking some additional functionality you want to add, consider creating a subclass (a class which builds on the functionality of an existing class, rather than defining all of its own functionality). For example, if you want to create a class that will be a visual object on the screen, you'll want to use the behavior of one of the existing display objects (for example, Sprite or MovieClip) as a basis for your class. In that case, MovieClip (or Sprite) would be the base class, and your class would extend that class. For more information about creating a subclass, see Inheritance.

Flash CS3


 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/9.0/main/00000032.html