Though we have already spoken about OOP and its features and attributes now its time to speak about another feature called encapsulation. Well, this is again another feature that is related to class, objects, and programming language. The programming languages are really important to us now since the hype of gaming apps and the other concepts are getting updated so its high time that we get to know about the behavior of programming. So, lets us start with the topic encapsulation. It is one of the fundamental concepts in object-oriented programming which describes the idea of packing data and methods which work on that data in a single unit. Well as the name suggests, encapsulation we are capturing the data in a private way to segregate it from the outer world. This is an idea used to hide the inner representation of an object from outside.
Before coming to data encapsulation let us talk about data abstraction. An abstraction could be a description of the essential properties of the associate entity that area unit of interest. That is, exposing all the necessary details and hiding the rest. In order to method one thing from the real world, we’ve got to extract the essential characteristics of that object.
Abstraction is the process of reducing an object to its essence so that only the necessary elements are represented. Abstraction defines an object in terms of properties, attributes, behaviors, functionality, and interface. The interface is the means of communicating with the other objects. So, the 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 depends on the task involved. Abstractions provide an external view of the entity. The task of the programmer, given a problem, is to determine what data needs to be extracted in order to adequately design ultimately code a solution.
Normally with a good problem description and/or good customer communication, this process is relatively painless. Classes are the java contrasts used to define abstractions of entities of interest. A class describes the essential properties of the type of entity than its instances represent. Different classes might be required to describe the different abstractions of the same type of entity. Abstractions are relative to the perspective of the viewer Abstraction focuses upon the essential characteristics of some object, relative to the perspective of the viewer.
Encapsulation is one step beyond abstraction. Whilst abstraction involves reducing a real-world entity to its essential process characteristics, encapsulation extends this idea by additionally modeling and linking the practicality of that entity. Encapsulation permits an object to separate its interface from its implementation. the info and therefore the implementation code for the article ar hidden behind its interface. Encapsulation hides the inner implementation details from users. It ensures that an object provides solely the requested data to a different object and hides inessential data.
It is basically the process of implementing object details which are data and functionality in a way that so that inessential information remains hidden but accessible through a visible interface. But sometimes, the user needs to access or obtain the value of hidden fields. In such a case instead of making the3m public its better to have accessor methods for each of the hidden fields of the class. However, we cannot hide the entire object. To use an object, a part of it needs to be accessed by the user. To provide access, abstraction is used. Abstraction provides access to a specific part of data while encapsulation hides the data.
Therefore, abstraction and encapsulation complement each other.
Since encapsulation hides the implementation of abstraction from its user or clients so encapsulation is often referred to as information hiding. The key rule of encapsulation is:
Only the interface to an abstraction should be known to its clients whereas how the interface is implemented is hidden from the user. Now let us know what is an interface that we are speaking about. The notion of an object’s interface is a commonly accepted concept in the object-oriented community.
Through the Encapsulation, only a predetermined group of functions can access the data. The collective term for data types and operations bundled together with access restrictions that are public or private is a class. In any case, the choice is invisible to the clients of our data class is because we have declared that as private and our choice of access modifiers show us how to exactly describe a class.
The single and most important factor which distinguishes a well-designed OOP module is the degree to which the module hides the internal data and its other implementation details from the other modules. A well-designed module hides all its implementation details, clearly separating the interface from its implementation. So this was all that we needed to know about the feature named data encapsulation of the OOP.
The three types of encapsulation in In Object Oriented Programming.
1. Member Variable Encapsulation
2. Function Encapsulation
3. Class Encapsulation
Advantage Of Encapsulation
Data Hiding, Increased Flexibility, Reusability, Testing code is easy, The fields of a category are often made read-only or write-only. A class can have total control over what’s stored in its fields. That will provide you total control over the info. It is quite easy to check.
Crawl Space Encapsulation
Encapsulating, or a minimum of sealing, crawl spaces is becoming a well-liked solution for avoiding indoor moisture issues. To the typical person, encapsulation is often compared to the liner added to swimming pools to avoid leaks. A heavy-duty polyethylene barrier is added to completely cover in your crawl space – Basically the floors, foundation walls, and sometimes even ceiling. This water vapor barrier is best when it completely covers your crawl space and sealing tape is employed to attach the barrier pieces throughout your area.
Once your space is totally sealed, the ultimate piece of the encapsulation puzzle is conditioning the air to take care of a healthy humidity level. the foremost common thanks to doing that are by adding a dehumidifier to manage your crawl space’s moisture level.
This barrier and dehumidifier combination protects the crawl space from excess moisture and every one the issues that come alongside it.
Here are common signs that lead people to seal their crawl space:
High cooling costs
Mildew/musty smell in basement
Soft or separating floors
(image source google search)