Object Oriented Programming – Abstraction

May 27th, 2008

Abstraction is a concept which facilitates to extract out the essential information of an object.

In OOP ( Object Oriented Programming ) , Abstraction facilitates the easy conceptualization of real world objects into the software program.

Abstraction lies everywhere! What ever you see, do and live are all full of abstraction.

In mathematics, multiplication is a kind of abstraction. The symbol “x” is an abstract symbol that can do multiplication of any two elements.

2 x 3 = 6

3.5 x 3.7 = 12.95

(a + b) x ( a – b) = a^2 – b^2

In Art, Abstract Art is a kind of art, which depicts the distilled form of the world.


Courtesy: RegiaArt

So, what exactly an Abstraction is?

Abstraction facilitates the easy conceptualization of real world objects, by eliminating the unnecessary details of the object. Unnecessary details? Yes, all the similar objects when you generalize, you will drop the uncommon details about the objects.

E.g., when you model a generic prototype for CRT Television & a Plasma Television, you look for details like Type of screen, Height, Width, thickness etc.; these are necessary details for a Television. But a Television object doesn’t need to have details of what kind of Electron it will bean to power the CRT, what kind of liquid plasmas it will use to power the Plasma TVs. These kinds of details are unnecessary details.

Let’s take mobile phone as the real world example. Look at the below mobile phones.


What do you feel about them?

  • Firstly, everything is Nokia Mobiles
  • You could see Slide, Flip and Bar models
  • You could see Music, Business & 3G Mobiles
  • You could see QWERTY , Basic and No keypads
  • You could extra music player button on music edition.
  • The Color, Size, Weight, Look etc…
  • And even more…

So, for better understanding I organize the mobile phones in the below format.


Basically, all the mobiles belong to Nokia.

Still need a better classification, I drill down to its features and conceptualize the mobiles in more general way. So, you could categorize the mobiles as

  • Music
  • Business
  • Gaming
  • Normal
  • 3G

As a layman user, you will feel its weight, color, style. As a music lover, you will check for the memory, type of media files it supports, and type of communication between devices (Bluetooth, Wi-Fi etc). As a business person, you will check for the memory, type of business application etc.


Now, you have got the details of the each and every mobile. It’s time to extract the most essential details of these mobile categories. Here I use an Abstraction filter, which abstracts out the essential details. So, essential details, here I mean is the most common properties of the mobiles.

So, now the conceptualization of mobile has still got finer. Now you can still go deep and get a finer concept to model a generic / abstract mobile, which can be turned into a beautiful mobile of your kind.


Now, you have extracted out the necessary details for each category of mobile. You still fine grain it to get a mobile phone’s basic property with the Abstraction filter.


Now, here comes your basic design of the Nokia mobile phone. You have learnt how you will abstract properties from the real world objects. Now the question is how you do it in the programming language. In the Object oriented principles, abstraction is achieved via Inheritance (a widely used design pattern)

The class diagram for the Nokia mobile using Inheritance look like below


You would have missed to understand the abstraction in the computer science. Here are few places where you could see how the abstraction works

  • Network Layers – OSI Model
  • Database Architecture – Data Abstraction ( Physical, Logical , View )
  • Polymorphism – Abstraction of Actions / Methods
  • Templates in C++ or Java – Abstraction of Common Objects
  • Data Structures – Abstract way to store & retrieve the data
  • Many more…

One important thing you need to remember is ‘Abstract objects’ never exists in real world. It is just the concept that we build to understand the working of real world objects.

E.g., There is nothing is called a Television, you have CRT Television (this is known commonly as TV), Plasma TV or LCD TV.


11 Comments

  1. ganesh
    Posted June 11, 2008 at 9:15 am | Permalink

    neatly explained concepts..

  2. Raj
    Posted August 26, 2008 at 10:27 pm | Permalink

    Mahesh,
    Its very interesting to read your article. You have explained the concept in an easy way to understand. Thanks for your posts.

  3. Posted August 27, 2008 at 6:45 am | Permalink

    Raj, thanks for your comments :-)
    Your suggestions are always welcomed!

  4. Rahul Jain
    Posted December 24, 2008 at 7:43 pm | Permalink

    there is a very gud way to explain any topic.and also i like this bcz u give many more unnique eg. to define anything.its better gud

  5. Posted December 24, 2008 at 7:51 pm | Permalink

    Thanks Rahul!!

  6. Harmeet
    Posted September 16, 2009 at 6:54 pm | Permalink

    I have read both of your articles and they are really superb. You have described the concepts in very easily and in simple way. Hats off to you man :) .

    I’m wonder when would you release your next article

  7. chandrashekar
    Posted June 11, 2010 at 11:50 am | Permalink

    Am speachless, no one has explained abstraction better than you. Thank you so much.

  8. Carla Muntean
    Posted November 8, 2010 at 2:06 pm | Permalink

    Love your way of explaining things. Back in high-school I had a teacher similar to you. I think it’s because of him I love programming. I would love you to post something similar about subtype (polymorphism) if you can.

    Thanks

  9. Posted December 12, 2010 at 3:32 pm | Permalink

    Reading blogs in general bores me and it’s hard to catch in all this, if you do not follow up a blog from the beginning. Unfortunately, blogs, mostly with what we have to do is just boring and not very transparent, so you can very quickly discouraged. Therefore, I stopped for some time be interested in what people place on their blogs. But appeared in the Internet space, this blog has completely changed my approach to this type of service. There are no boring thoughts on it on trivial subjects or superficial articles that talk about nothing. If we are interested in precisely this theme, it’s worth a look at this blog and read. I am very surprised that so interesting you can solve the same graphics and layout of content. Such steps make it a blog is very clear and readable. His coloring is friendly to the eyes and spirit. Of course, many people could now resented and recognize that it is not that important, but if you spend on the internet a bit more time and read more, you will surely appreciate the fact that an appropriate image, which does not strain our eyes. Therefore, even if the color of your blog are of great importance, which is discovered in time. This blog I discovered not so long ago, but immediately interested me. At first it was curiosity about the same form, layout, content and divided into categories. However, when I began to read. It turned out that this blog conceals a much more interesting content than might be assumed at the beginning. This blog though it looks like a typical blog with better graphics, after all, a little different from the other pages of this type, which I have visited. First of all, because the information that you find here are really valuable. In other sites, you can often find the writing for the sake of writing, because in such cases only wasting time. This blog breaks away from the trash, so that only people who are really looking for information, may be interested in it. Keep up the invite to your blog pozycjonowanie stron

  10. Posted November 5, 2011 at 2:35 am | Permalink

    Poker-online is undoubtedly an perfect Pastime yet you need to discover the Policies.

  11. Posted February 5, 2012 at 1:55 pm | Permalink

    I would like to thank you for the efforts you’ve put in writing this site. I’m hoping the same high-grade web site post from you in the upcoming as well. In fact your creative writing skills has encouraged me to get my own website now. Actually the blogging is spreading its wings fast. Your write up is a good example of it.

2 Trackbacks

  1. [...] the Object Oriented Programming series, after writing about Abstraction, it’s time to educate about [...]

  2. By Abstraction and OO Paradigm « Glocal Design on August 23, 2009 at 6:55 pm

    [...] http://www.mymindleaks.com/blog/programming/object-oriented-programming-abstraction/ [...]

Post a Comment

Your email is never shared. Required fields are marked *

*
*