Abstraction
- Abstraction is Only showing what is necessary and encapsulating (hiding) unnecessary parts.
- If you take a car you interact with it using abstractions
- you use gas pedal, steering wheel which hides internal details
- It is keeping a clear separation between abstract properties of a data type and the concrete details of its implementation.
- It is not presenting the details but only show the parts which are necessary.
- Hiding implementation
Encapsulation :
- Hiding state/data. Information hiding mechanism
- It is the opposite of Abstraction.
https://www.google.com/search?q=encapsulation+vs+abstraction&ie=utf-8&oe=utf-8
http://stackoverflow.com/questions/742341/difference-between-abstraction-and-encapsulation
Composition : Combining simple types to make a complex type (Car composed of Wheels, Body etc.). An object of a composite type "has an" object of a simple type.
Is a form of object composition.
Inheritance : When an object or class based on another object or class.
Inheritance is "is a" relationship while, composition is "has a" relationship
Articles
- inheritance defined statically at compile time.
- object composition defined dynamically at run time, through objects acquiring references to other objects
- inheritance : reuse by subclassing : white box reuse (internals of parent are visible)
- composition : well defined interfaces: black box reuse (no internal objects are visible)
updated: 2014