Abstraction vs Encapsulation - Principles of Object Oriented Programming (OOPS)

Abstraction
In order to process something from the real world we have to extract the essential characteristics of that object.
Data abstraction can be viewed as the process of refining away the unimportant details of an object, so that only the useful characteristics that define it remain. Evidently, this is task specific.

Encapsulation
Encapsulation is one step beyond abstraction. Whilst abstraction involves reducing a real world entity to its essential defining characteristics, encapsulation extends this idea by also modeling and linking the functionality of that entity. Encapsulation links the data to the operations that can be performed upon the data.

OOP makes use of encapsulation to enforce the integrity of a type (i.e. to make sure data is used in an appropriate manner) by preventing programmers from accessing data in a non-intended manner


Through encapsulation, only a predetermined group of functions can access the data. The collective term for datatypes and operations (methods) bundled together with access restrictions (public/private, etc.) is a class

No comments:

Post a Comment

Please Provide your feedback here