Wednesday, July 3, 2013

Object Oriented Programming Basic Concepts

Object oriented programming is useful for many aspects:
1. Code reuse.
2. Better design


Encapsulation: Hiding data and behaviour of an Object and provide interface (public methods) to outside objects to access data. It helps in preventing users from setting objects state directly which can cause inconsistency.

Inheritance: Way to establish relationship between objects. Here class inherit properties and method of parent class. Inheritance is termed as "Is a relationship" (Parent-Child relationship)

Polymorphism: Means many forms. Similar type of objects can behave differently for same message.
It is tightly coupled with Inheritance. Parent class provide interface(method) which is implemented differently by different child classes.


No comments: