Monday, December 14, 2015

Encapsulation


   >>> Storing data and function in a single unit (class) is encapsulation.

   >>> Binding the data and code to access that data. Encapsulation only refers to a container, which has a data and its related function in it.

   >>> Classes provide one of the most common ways to encapsulate items. Data cannot be accessible to the outside world and only those functions, which are stored in the class can access it.

   >>> Encapsulation is the the ability to contain and control the access to a group of associated items.

   >>> The data is not accessible to the outside world and only those functions, which are wrapped in the class can access it. These functions provide the interface between the objects's data and the program.

   >>> Encapsulation also allows you to control how the data and procedures are used. You can use access modifiers such as private or protected to prevent outside procedures from executing class methods or reading and modifying data in properties and fields.

   >>> You should declare internal details of a class as private to prevent them from being used outside your class; this technique is called data hiding.

   >>> Rememberer that encapsulation means that the attributes (data) and the behaviours (code) are encapsulated in to a single object.

No comments:

Post a Comment