Encapsulation – Information Hiding in Object Oriented Design
Programming ....
|
|
Objects have internal details and an external interface. This is a form of information hiding. No-one but the objects have access to the internal details.
|
|
This offers two advantages:
- Objects control what can happen to them
- Outsider is not exposed to the internal details of the object
Why would we like to hide internal details of the object?
Encapsulation separates clients and implementers. Client code can evolve independently and implementation details can be changed without impacting clients.
Parnas Principles:
The developer of a software component must provide the intended user with all the information needed to make effective use of the services provided by the component, and should provide no other information.
The implementer of a software component must be provided with all the information necessary to carry out the given responsibilities assigned to the component, and should be provided with no other information.
Parnas Principles leads to a “component” having two faces:
- Internal: implementation details
- External: usage information
Encapsulation is normally meant to separate private data from methods but Parnas principles are meant for all kinds of components: classes, groups of classes, modules, and components.


Prashant Mhatre
Make Money, Programming, Bollywood, Marathi
^_*