Abstraction: Amplify The Essential-Eliminate The Irrelevant

 < Day Day Up > 



Abstraction allows you to tame software conceptual complexity. When designing class types your goal must be to identify the essential features of that class of objects. If you're designing a base class the essential features identified must also apply to all possible subclasses. The notion of essentiality can be reduced to pure abstraction by the creation of an abstract base class containing only a public interface comprised of pure virtual functions.

The irrelevant manifests itself in the implementation and thus encapsulation is used to hide implementation details. Implementation can be further removed from interface by placing implementation details in a separate class from that which declares the interface. You will see an example of this later.

Abstraction and inheritance are force multipliers. By using them you gain an incredible amount of power to reduce conceptual complexity, treating groups of different objects the same via a shared interface. This grouping of objects via a shared interface is an important concept that allows us to ignore the differences between derived class objects and treat them all the same as figure 16-1 illustrates.

click to expand
Figure 16-1: Base Class Declares Behavior Shared By All Derived Class Objects

As it turns out, most of the difficulty of any software design lies in getting the abstractions and inheritance relationships just right. One false move and you'll soon discover you have programmed yourself into a corner from which the only escape leads to design rot. Proficiency in this matter is gained only through experience.



 < Day Day Up > 



C++ for Artists. The Art, Philosophy, and Science of Object-Oriented Programming
C++ For Artists: The Art, Philosophy, And Science Of Object-Oriented Programming
ISBN: 1932504028
EAN: 2147483647
Year: 2003
Pages: 340
Authors: Rick Miller

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