Click here to Skip to main content
15,891,908 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can any one reply these questions?

1. How can we decide when to use Abstraction or interfaces( ie In which scenario we decide to use either of one)

2. What is the advantage of using Abstraction?

Kindly provide some real life examples
Posted

First let me clear one thing, their is difference between terms "Abstraction" and "Abstract Class".

I guess you want to know difference between "Interface" and "Abstract Class".

Below Article may help you in understanding "Abstraction", "Abstract Class" and "Interface".
Introduction to Object Oriented Programming Concepts (OOP) and More

Updated -
Here is one more good Article on Object Oriented Programming concepts.
How I explained OOD to my wife
 
Share this answer
 
v2
Comments
Simon Bang Terkildsen 3-Oct-11 3:39am    
Very good point, I just read it as abstract class. And that's one great article!
My 5
RaisKazi 3-Oct-11 3:44am    
Thank you Simon :)
If you read the following, you can have a better idea.

Abstract Class versus Interface[^]
 
Share this answer
 
Here's a short answer

1) Go for an abstract class when the sub classes will share behavior, so the concrete implementation of these shared behaviors would be placed in the abstract class. if the sub types won't share behavior go for an interface.

2) You can implement behaviors/features in an abstract class which you can't with an interface. However it's only an advantage if the sub classes share these behaviors/features.

I suggest you read this book Object-Oriented Software Construction[^] if want very good insight into software design.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900