Under the hood, there is a lot that will happen now. We press a button on the machine which sends it a command to internally clean it. This is a process that we may want to do every once a week or two so that our coffee machine stays clean. We work with abstracted processes that under the hood use hidden processes to execute an action.Ĭircling back to our coffee example, let’s say our coffee machine has a function to internally clean the entire empty machine for us. In process abstraction, the underlying implementation details of a process are hidden. Where data abstraction works with data, process abstraction does the same job but with processes. As programmers, we don’t need to know what the underlying entity is, how it looks etc. Therefore, data abstraction refers to hiding the original data entity via a data structure that can internally work through the hidden data entities. I can use the hazelnut coffee beans directly without worrying about how the original coffee beans were made to add the hazelnut flavour to it. In this case, the hazelnut coffee bean itself is an abstraction of the original data, the raw coffee beans. So I can directly add the hazelnut coffee beans and the coffee machine treats it as just any other regular coffee bean. Luckily, there’s a new type of coffee powder or processed coffee beans that already have hazelnut in it. Let’s say that I need a special hazelnut coffee this time. Let’s go back to our example of making coffee. This object represents some data but the underlying characteristics or structure of that data is actually hidden from you. When working with OOPS, you primarily work on manipulating and dealing with complex objects. Data Abstractionĭata abstraction is the simplest form of abstraction. Let’s take a quick peek into both of these. The second one is process abstraction which hides the underlying implementation of a process. One is data abstraction which pertains to abstracting data entities. There are primarily two types of abstraction implemented in OOPs. But you don’t need to understand how this method is implemented and which kinds of actions it has to perform to create the expected result. Similar to the coffee machine in your kitchen, you just need to know which methods of the object are available to call and which input parameters are needed to trigger a specific operation. Objects in an OOP language provide an abstraction that hides the internal implementation details. You can use the same concept in object-oriented programming languages like Java. You just interact with a simple interface that doesn’t require any knowledge about the internal implementation. Someone else worried about that and created a coffee machine that now acts as an abstraction and hides all these details. You don’t need to know the ideal temperature of the water or the amount of ground coffee you need to use. The thing you don’t need to know is how the coffee machine is working internally to brew a fresh cup of delicious coffee. You need to provide water and coffee beans, switch it on and select the kind of coffee you want to get. You need to know how to use your coffee machine to make coffee. Making coffee with a coffee machine is a good example of abstraction. So, when I wake up in the morning, I go into my kitchen, switch on the coffee machine and make coffee. You can find it everywhere in the real world. That’s a very generic concept that’s not limited to object-oriented programming. That enables the user to implement more complex logic on top of the provided abstraction without understanding or even thinking about all the hidden complexity. Its main goal is to handle complexity by hiding unnecessary details from the user. Abstraction is one of the key concepts of object-oriented programming (OOP) languages.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |