Encapsulation

Monday, January 14, 2008

Encapsulation

Encapsulation

In object-oriented programming, objects interact with each other by messages. The only thing that an object knows about another object is the object's interface. Each object's data and logic is hidden from other objects. In other words, the interface encapsulates the object's code and data.


This allow the developer to separate an object's implementation from its bahavior. This separation creates a "black-box" affect where the user is isolated from implementation changes. As long as the interface remains the same, any changes to the internal implementation is transparent to the user. For example, if the name message is sent to the Student object, it does not matter to the user how the developer implemented the code to handle this message. All the sending object needs is the correct protocol for interacting with the Student object. The developer can change the implementation at any time, but the name message would still work because the interface is the same.

0 comments:

 

Tamil Video Songs | Make Money Online