Monday, 15 August 2011

Java: Encapsulation and Abstraction

Abstraction, briefly mentioned before, is the way we capture the important aspects of something while ignoring the unique details between individual things. A chair, as opposed to a red cushioned mahogany etc etc. This is important to help people understand complex systems, as well as communicate and reason about them. Without abstraction, the level of detail required to understand systems is enormous, leaving people to be unable to build the object mentally.

Close to the idea of abstraction is encapsulation, a mechanism meant to ensure objects have a definitive inside and outside. The insides are protected from the outside, preventing any arbitrary changes to them. Once encapsulation is in place, the only way to access the abstract object is via some interface visible to the outside, keeping the actual workings of the inside hidden from view. They're not needed to make use of the abstraction.

Defining and making use of these 2 concepts is basically the main point of programming, especially with an Object Oriented language like Java.


Interested in reading ahead? I'm using "Developing Java Software" by Winder and Roberts, Third Edition.
Questions or concerns? Feel free to post a comment, I'm learning this freshly, so I might well have not explained something fully, or explained it completely wrong, feedback appreciated.

No comments:

Post a Comment