Thursday, September 6, 2012

OO Programming

Polymorphism

When a function or an object can take on different forms. Inheritance and virtual functions in C++, are an example of this.

Encapsulation

When you restrict access to parts of an object. Singleton pattern, Factory pattern, getters and setters are examples of this.

Composition

Aggregating simple objects into more complex objects (ie. when an object is made up of other objects). This is a good way of reusing code. For example, a car object, can contain a window and stereo object.

No comments:

Post a Comment