Blog
Entity Component System
What is Entity-Component-System? Entity-Component–System (ECS) is an architectural pattern. This...
Abstraction is an OOP concept that focuses only on relevant data of an object. It hides the background details and emphasizes the essential data points for reducing the complexity and increase efficiency. It generally retains only information which is most relevant for that specific process. Abstraction method mainly focusses on the idea instead of actual functioning.
In this tutorial, you will learn
Encapsulation is a method of making a complex system easier to handle for end users. The user need not worry about internal details and complexities of the system. Encapsulation is a process of wrapping the data and the code, that operate on the data into a single entity. You can assume it as a protective wrapper that stops random access of code defined outside that wrapper.
Here, are the main reasons why abstraction is needed for Object-Oriented Programming:
The main advantages of encapsulation are
Suppose you want to create a banking application and you are asked to collect all the information about your customer. There are chances that you will come up with the following information about the customer.
But, not all of the above information is required to create a banking application.
So, you need to select only the useful information for your banking application from that pool. Data like name, address, tax information, etc. make sense for a banking application.
Since we have fetched/removed/selected the customer information from a larger pool, the process is referred to as Abstraction.
However, the same information once extracted can be used for a wide range of applications. For instance, you can use the same data for hospital application, job portal application, a Government database, etc. with little or no modification. Hence, it becomes your Master Data. This is an advantage of Abstraction.
Let's take an example of mobile device. With the help of mobile devices, you can perform various functions like taking a picture, sending a message, recording video/ audio, access the web and much more.
The features mentioned above are functionalities of most of the smartphone. However, you don't need to understand the internal functioning details of those features before using this program. Example, you don't need to know how your camera calculates gamma correction or identifies a human face in an image. You just need to learn the software interface. This is encapsulation.
Parameter | Abstraction | Encapsulation |
---|---|---|
Use for | Abstraction solves the problem and issues that arise at the design stage. | Encapsulation solves the problem and issue that arise at the implementation stage. |
Focus | Abstraction allows you to focus on what the object does instead of how it does it | Encapsulation enables you to hide the code and data into a single unit to secure the data from the outside world. |
Implementation | You can use abstraction using Interface and Abstract Class. | You can implement encapsulation using Access Modifiers (Public, Protected & Private.) |
Focuses | Focus mainly on what should be done. | Focus primarily on how it should be done. |
Application | During design level. | During the Implementation level. |
What is Entity-Component-System? Entity-Component–System (ECS) is an architectural pattern. This...
In this tutorial, you will learn: What are the Data Types in R? Variables Vectors Arithmetic...
Music streaming services are online applications that help you to listen to your favorite songs...
Following are frequently asked questions in interviews for freshers as well as experienced Java...
You can use the geometric object geom_boxplot() from ggplot2 library to draw a boxplot() in R....
M4V to MP4 converter is an application that can convert M4V (iTunes Video) files to MP4 (MPEG-4...