R Programming
SAS vs R: What's the Difference?
What is SAS? SAS stands for S tatistical A nalysis S oftware which is used for Data Analytics. It helps...
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 SAS? SAS stands for S tatistical A nalysis S oftware which is used for Data Analytics. It helps...
MP3 Downloaders are applications that enable you to download pop, electronic, rock, and jazz songs with...
While working on a Linux operating system, you may need to communicate with other devices . For...
{loadposition top-ads-automation-testing-tools} What is DevOps Tool? DevOps Tools help automate the...
What is Apache Flume in Hadoop? Apache Flume is a reliable and distributed system for collecting,...
Defragmentation is a process that physically organizes the content of your hard disk and stores...