Understanding Classes

 <  Day Day Up  >  

Objects begin as ideas or concepts that eventually become part of a solution. Think of the process as a puzzle, where each unique piece has a place in the final picture. For the puzzle to fit together, each piece must be carefully considered in regards to how it fits. This is accomplished with a blueprint methodology. Each object's defining characteristics are outlined in a blueprint or class definition.

A class definition is much like an architectural blueprint, which identifies what a house will look like and what amenities it will have. A blueprint can be used many times to create many houses . The blueprint guarantees some similarities in all houses built from the blueprint.

The blueprint might include details such as the following:

  • Number of rooms

  • Room dimensions

  • Heating system

  • Plumbing systems

  • Electrical system

  • Window frames

  • Air conditioning

Each element describes what shape the final house takes and how it performs . You could say that these are the properties and functions of the house.

In OOP, the blueprint of an object is called a class definition. It defines what the object does and identifies its associated data. Therefore, a class definition is a blueprint for an object that defines its properties and functions (called methods in OOP).

What if an architect had to design every element of a new house? Finding an architect who is also a plumbing and heating expert might be a challenge. A better choice would be to have a heating expert design and build the heating system, a plumber to do the plumbing work, and so on.

Many of the components of the house can be prebuilt. Using prebuilt objects, the complexity of building a house is greatly reduced. Prebuilt objects are tested and guaranteed by experts in the problem domain. Individual objects can be replaced without rebuilding the entire system. For example, if you decide to upgrade your heating system to a more energy-efficient system, you don't have to build a new house from scratch. You can simply replace the existing system.

When we apply object-oriented principles to the problem of building a new house, we can say the following:

  • A house is made up of objects interacting with each other. For instance, turning up the thermostat sends a message to the heating system to heat the house.

  • Building a house involves many different systems that are brought together for a common goal ”to provide shelter.

  • Each object in the house has a well-defined role. The roles include heating, plumbing, and so on.

These same principles apply in object-oriented application development:

  • An application is made of objects interacting with each other.

  • Creating a program involves assembling objects and making them communicate.

  • Each object has a well-defined role in the system.

Using these principles enables real-world concepts to be modeled in a computer program. In ActionScript 2.0, there are many new constructs to help us employ solid object-oriented techniques in Flash MX 2004.

 <  Day Day Up  >  

Object-Oriented Programming with ActionScript 2.0
Object-Oriented Programming with ActionScript 2.0
ISBN: 0735713804
EAN: 2147483647
Year: 2004
Pages: 162

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