?
Solved

"Abstraction" - OOPS Definition - Explanation in C# / VB.NET

Posted on 2007-10-02
20
Medium Priority
?
19,998 Views
Last Modified: 2013-12-17
Hi,

I am looking into "OOPS" - Object Oriented Programming Concepts. I have the following definition for "Abstraction". Can you please explain / justify me this concept in simple terms ? Even though this seems to be simple but i want to understand what does this mean !!

Definition:
========

"Abstraction" refers to the act of representing essential features without including the background details or explanations. Classes use the concept of abstraction and are defined as a list of abstract attributes.

Appreciate your help !
0
Comment
Question by:kishore_peddi
  • 6
  • 5
  • 4
  • +2
19 Comments
 
LVL 23

Expert Comment

by:Ashish Patel
ID: 20004178
Abstraction, if a class which you create as abstract class, then this class is just like a blue print of the class structure without any details or process logic. And when you imply this class to any sub class then you will have to use the structure of this abstract class as blue print.
0
 
LVL 14

Expert Comment

by:Jai S
ID: 20004182
abstract - in plain english 'Theorotical' which means that its in theory...
so when you say that you create an abstract class it is only the DEFINITION and not the usage...
the main idea (one of the ) behind creating abstract class / methods are to list down the structure of how your derived classes must be and what methods are to be overridden by them in order to perform the DERIVED objects specific needs...
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 20004279
If you study philosophy, plato might have called it a universal.

It is an ideal... a set of functionality/properties which have been brought up to another level.

A great example of an abstraction can be seen in the definition of species ... A mammal contains similarities between both mice and humans. In its term it can easily describe that we both give birth to live young, have warm blood, and have hair. By providing the abstraction of a mammal we can talk in similarity about mice, humans, or a species you have might never heard of (The Houynhnms from Gulliver's Travels) and you can understand something about them based upon the fact that they meet the mammal abstraction.

There are many abstractions in language ... say I were to say the words 'TVR Tuscan' you may not know what they mean but if I said 'sports car' you know! ... This is because sports car is an abstraction that describes the TVR Tuscan as well as other fast, well handling, and generally desirable by males in their 20s cars..

While the above is in specific geared towards polymorphism ... In the same way; in computer science abstraction groups objects of similar  functionalities ... Abstraction can be seen as a case like the above or as simply as hiding internal details of an obect from other objects ...

Cheers,

Greg
0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
LVL 22

Expert Comment

by:JimBrandley
ID: 20004298
Both of these responses tell you about abstract classes, but don't really hit on the concept of abstraction. The general OO concept of abstraction means that for any object, it is important to separate gory details from the picture the object presents to the outside world. For example, say you have instantiated a telephone class. There is a public method you can invoke that will tell it to dial a specific phone number. You are a consumer of that telephone class. You tell it to DIAL( 218-555-1212 ).

You do not care whether it sends tones or pulses over a copper wire or whether it routes through VOIP, you just want the telephone to place a call.

There are two advantages to that.
1. As a caller, you do not need to know anything about how telephones are dialed, and
2. The smart people who write the detail code for dialing may find a faster, better, cheaper way to do the job, and your code doesn't need to change at all.

That is the OO concept of abstraction.

Jim
0
 
LVL 22

Expert Comment

by:JimBrandley
ID: 20004324
As Greg pointed out, abstraction and polymorphism can be combined. You base mammal class might have an abstract method called Speak(). It needs to be overridden in each derived class. If you have a Dog or a Cat or an Elephant, if you invoke the Speak() method something is going to happen, and it will likely be different for each derived class.

Jim
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 20004398
Of couse for a proper abstaction you would probably not put Speak() on mammal ... surely a frog can speak yet it is not a mammal. Thus we may even end up with a SpeakingAnimal abstraction which defined Speak and all mammals (though I doubt they can all speak, note 'mute human') would thus be abstracted as SpeakingAnimals. Unfortunately while the concept of abstraction is easy to grasp in practice edge conditions (or new discoveries/forgotten cases) often cause drastic changes in your abstractions :)

Cheers,

Greg
0
 

Author Comment

by:kishore_peddi
ID: 20004418
Jim,

Great explanation. But then what is the difference between "Abstaction" and "Encapsulation" ? No difference ? These two are different in OOPS...please correct me if i am wrong !!
0
 

Author Comment

by:kishore_peddi
ID: 20004428
mmm...sorry..."Abstraction" and "Hiding"....No difference ?
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 20004442
Encapsulation can be a form of abstraction! abstraction though is a broader term. In lnguage abstraction tends to equate to polymorphism.
0
 
LVL 22

Expert Comment

by:JimBrandley
ID: 20004550
It does get to be confusing. As Greg just pointed out, encapsulation and abstraction are related. Go back to the Telephone class. All the stuff to dial a phone is encapsulated. But it doesn't do any good it you can't get to it somehow. So, you are presented with an abstraction of that Behavior in the method invocation called Dial().

Greg's mention of Frogs brings up another good point. Lots of animals can speak. In C++, I could derive Frof from Amphibian and SpeakingAnimal. I could derive Dog from Mammal and SpeakingAnimal. I think the biggest loss in the move to C# was the loss of multiple inheritance. I know it caused me to write a lot of duplicated code.

Jim
0
 

Author Comment

by:kishore_peddi
ID: 20011237
So Jim,

Thanks for your info. BTW Is this the same thing i can call "Hiding" ? Am i correct ?

Thanks

0
 
LVL 22

Expert Comment

by:JimBrandley
ID: 20011256
Correct - Encapsulation and Hiding are different terms for the same thing.

Jim
0
 

Author Comment

by:kishore_peddi
ID: 20011597
Here is the summary:

"Abstraction" and ""Hiding" are same. But "Encapsulation" is nothing but encapsulating "Members and Methods". Please correct me if i am wrong !!
0
 
LVL 14

Expert Comment

by:Jai S
ID: 20011606
No, Absctraction is not HIDING...Encapsulation is termed as HIDING...
0
 

Author Comment

by:kishore_peddi
ID: 20011618
In this scenario,

=================================================================================
Both of these responses tell you about abstract classes, but don't really hit on the concept of abstraction. The general OO concept of abstraction means that for any object, it is important to separate gory details from the picture the object presents to the outside world. For example, say you have instantiated a telephone class. There is a public method you can invoke that will tell it to dial a specific phone number. You are a consumer of that telephone class. You tell it to DIAL( 218-555-1212 ).

You do not care whether it sends tones or pulses over a copper wire or whether it routes through VOIP, you just want the telephone to place a call.

There are two advantages to that.
1. As a caller, you do not need to know anything about how telephones are dialed, and
2. The smart people who write the detail code for dialing may find a faster, better, cheaper way to do the job, and your code doesn't need to change at all.

That is the OO concept of abstraction.

Jim

I do not know the details behind the scenes. It is just giving me a method to invoke that object properties (ex: Dailing Phone). ?????
0
 
LVL 22

Expert Comment

by:JimBrandley
ID: 20030809
My first post on this thread came from a book I have had for a long time, called "C++ Primer+" by Stephen Prata, page 347.

Since then, I have looked at some other books and done some Googling. My conclusion is the the definition presented in this book, or my interpretation thereof, is incorrect. I apologize for creating confusion by presenting that as THE definition. It was one definition, and it was incorrect.

Based on further reading, Greg's first post is much close to the mark.

Jim
0
 

Author Comment

by:kishore_peddi
ID: 20197583
BTW:

Can any body give the exact definition for this so that i can close my listing please ? Appreciate your time and effort !!

Thanks
0
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 1000 total points
ID: 20197600
"abstraction - a general concept formed by extracting common features from specific examples"


0
 
LVL 14

Expert Comment

by:Jai S
ID: 20417015
i would suggest a point split between jimbrandley and gregoryYoung
0

Featured Post

Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question