29 September 2009

OOPS - What is Abstraction?

There is song in a movie in Tamil (Alavanthan) and the song sequence happens in a party. Everyone would crack joke and our hero would share a joke. Here it goes. "A little kid asks his parent. What is the meaning of sex? And their parents explain with a lot of struggle. and try to explain the meaning of sex. Finally the kid just asks, Should I check male or female in the application form". We, the developers, without understanding what is abstraction try to develop application. For a kid it does not make sense to say intricacies of something as it incapable of understanding that something (example, sex). The parents should abstract the idea in a form that is sufficient or needed for the level. And sometimes the details are not required.

Another example of abstraction in real world could be appearance of beach sand. For someone who sits on the beach, the sand will appear course but for someone who is traveling in an aircraft few kilometers above the sea level, the beach itself appears as a thin line. In the real world, the abstraction is quite common and we human being appreciate abstraction quite well.

Let us take another example. How will you tell your find that you are going home? Assuming that your home is in "Nanganallur, Chennai, Tamilnadu, India, Asia" and you are in S"an Jose, California, US, North America". You just say that you are going to India. But when you are in India, you give more specific address.

Yet another example of abstraction is someone taking bath. If someone is taking bath, you hardly worry what he is doing inside. You never try to investigate what someone is doing in bathroom. But the guy who is taking bath, he does it with a lot of details. You shed out details when it is not required. Interestingly, in real world you clearly know when to shed out details.

So abstraction is something that gets built up as you move up the hierarchy and you leave out details intentionally to make the concept more generic. Now again, go back and reread the real world examples. It should make sense. Then correlate with abstraction in object oriented programming.