CS Abstraction ~ Programming 101
Most of the people around us, whenever they encounter the word... programming, their eyes turn in horror and they quickly run to click somewhere else to a more friendly post. Even more so when it comes to specific programming terminology. Abstraction. If you are still here with me, after reading both these words, programming and abstraction, in the following lines I will try to explain computer science abstraction in a friendly and straightforward way.
Abstraction. There! I said it again! OK you are still here! So lets start by taking it from the start. Abstraction as a noun is the abstract notion or the general idea of a task or a situation. It is the act of keeping things simple in order to enjoy the practical side of complicated systems and increase a positive user experience. Similarly, in computer science, abstraction is understood as process that reduces complexity of an object by hiding irrelevant to its use detail, in order to increase efficiency. In other words, keep it simple!
If we had to know every nitty gritty detail about every task or situation we encounter and every object we use, we would probably suffer from disorientation while carrying around our large heavy heads containing accordingly large, full of massive encyclopedia-like detailed brains!
To understand abstraction in full length, we will take some examples from everyday life focusing on objects –in the most general idea of what an object is- we use to facilitate life. The first that comes to mind when I think what I use everyday, is my fridge. From as small research online about refrigerators I found out that refrigerators date back to the 11th century AC. Back then they were very large chambers, dark and cool, accessible from a front door. If you were to find yourself awkwardly, just like Philip J. Fry did in Futurama, back to the 11th century and survived through the day, you would at least have a fridge to store your food for the next day!
Some things never change, they say. And they are right! Although in the history of refrigerating, fridges have gone from large cool chambers, to storage with ice, to artificial mechanical refrigerators, to our modern automated compact fridges; at any point in these 10 centuries, the user experience would be the same. Open a door and store inside anything you want to stay cool.
So to say, this is the interface of the fridge. The door, or more accurately, the handle at the door is what we use to access the facilities. Although the interface has remained the same from the beginning of time, everything else behind it has changed.
To simplify our approach to the complicated vicious refrigerator in our kitchen we can split it function to layers. Bottom to top we have, space, cooling method, accessing method. Splitting it to layers enables us to discuss with our fellow new 11th century friend about fridges. What? Did you think that you just bump into one?! You will have to ask for directions!
In the programming world, as wikipedia defines, the programmer works with an idealized interface and can add additional levels of functionality that would otherwise be too complex to handle. For example, a programmer writing code that involves numerical operations may not be interested in the way numbers are represented in the underlying hardware (e.g. whether they're 16 bit or 32 bit integers), and where those details have been suppressed it can be said that they were abstracted away, leaving simply numbers with which the programmer can work. (source wikipedia)
Now, past the time travel and refrigerators, I believe we have reached to an agreement as for why abstraction is important for our sanity. But then why should we ever bother going into details about anything that is not our work? Let me share with you a story. When I first mastered riding a bicycle, around my 9 years in this world, I only needed to focus on the physical effort to go from one place to another. I did not need to know how the bicycle worked to enjoy riding it! Actually not knowing how it worked made my life easier. One day, I must have been around 13 now, I decided to visit by bike my mother at work, a good 13 km away from home. Everything went well, I found her and she was really proud of me. On my way back home I got a flat tire. I had to walk back the whole thing carrying the bike along. When I took it to a bike place I had them explain and show me how to change the tube, detail by detail till I was sure I will never walk 13 km again! In this example, the high level abstract idea are the wheels that a bike needs in order to move and taking a closer look, the tire containing an air tube, which is released by removing the nut or the using the quick release handle, would be the low-level details that need to be abstract away.
I hope you enjoyed reading this essay and you now have an abstract idea of what abstraction in programming is!
Irene very good examples, very well explained and written!