Data Hiding
Outside person can’t access our internal data directly or
internal data variable can’t be access directly from outside. This feature of
oops is called Data hiding. We can access these variables through methods.
The main advantage of this feature is to provide Security.
We can achieve this feature by declaring our variable as private variable.
The main advantage of this feature is to provide Security.
We can achieve this feature by declaring our variable as private variable.
Abstraction
Hiding the internal implementation and just Highlighting the
set of Service is called Abstraction.
We can achieve the Abstraction by using Abstract class or
interface in our program.
The main advantage of these feature are:
- We can achieve the security to next level.
- Enhancement of the system becomes easy without affecting the end user.
- It improves the maintainability of the system.
- It provides more flexibility to end user to use system easily.
Encapsulation
The process of binding data members (variables) and methods
into a single unit is called Encapsulation.
Technically if any unit follows data hiding and abstraction
then we say this unit follows encapsulation and it is encapsulated.
Encapsulation = Data
Hiding + Abstraction
Advantage of
encapsulation is similar as Abstraction.
The Disadvantage of encapsulation is it increases the length
of code and execution time will increase.
Tightly encapsulated
A class is said to be tightly encapsulated if and only
if each variable of the class is
declared to be private whether class contain corresponding setter and getter or
not and whether these methods declare
public or not.
It means for tightly encapsulation all variable must be private only.
If the parent class is not tightly encapsulated then its child class also not tightly encapsulated even if it declare its all variable as private.
It means for tightly encapsulation all variable must be private only.
If the parent class is not tightly encapsulated then its child class also not tightly encapsulated even if it declare its all variable as private.
No comments:
Post a Comment