OO Concepts

OO technology is based on several concepts that, when applied to a program, make the resulting product easier to extend and reuse.

Five concepts: Abstraction, encapsulation, specialization, type promotion, polymorphism


Ex: Sales Person - abstractions for 2 different applications (in class)

An abstraction is represented by an interface specification which specifies the behavior of the module.

A class defines an abstraction in the problem domain.


Ex: Defining properties of a class as private to the class is an example of encapsulation.

Class Specialization

1. The Kangaroo class is a specialization of the Animal class (i.e. Kangaroo is a kind of Animal).
2. The CashTextBox class is a specialization of the TextBox class (i.e. the TextBox class is a generalization of the CashTextBox class).

Inheritance: the specialization inherits all of the state and behavior of the generalization

(in class)

The concepts of abstraction and generalization are often confused:
Abstraction - simplify the description of an entity.
Generalization - look for common properties among the abstractions.

Specialization lets you define properties common to all animals in the Animal class - and then inherit these properties in the Animal specializations (Kangaroo, Dog, Cat, Lizard, etc). So you only have a single copy of these properties. If you had multiple copies of this code, corrections to the code would be made to each copy.

Note: Specialization is a common way of evolving existing object structures. But specialization should be used with care.

That is: Exercise Caution when creating Inheritance Hierarchies

Killer Kangas - An "Object" Lesson

Project:  Australian air force - virtual reality simulator for helicopter combat training


Possible Solution?

Type Promotion