08 February 2011

Encapsulation in OOP

(If you are finding this via a search results, be forewarned: I'm just learning this concept.)

Encapsulation: The practice in Object Oriented Programming of taking functionality and hiding it behind the scenes, so that it works seamlessly without the class user knowing how it is being accomplished.

As I'm thinking about this principle, it occurs to me that there is are abundant examples of encapsulation in use around me every day in my front-end programming work. For example, these days I rely heavily on Jquery to execute Javascript functionality. Jquery seems to me to be the perfect example of making Javascript work "behind the scenes" so that I haven't had to learn to detailed intricacies of Javascript and it's quirky browser specific behaviors.

And yet even more so, with Jquery itself there are more examples of encapsulation. For example, the .show() method, which is actually doing some other more advanced jquery execution, all behind the scenes without me knowing (yet) how it is being accomplished.

0 comments:

Email Marketing