Click here to Skip to main content
15,898,371 members
Home / Discussions / C#
   

C#

 
Question"interface and abstract" Pin
ravikiranreddydharmannagari15-Feb-07 23:58
ravikiranreddydharmannagari15-Feb-07 23:58 
AnswerRe: "interface and abstract" Pin
Stefan Troschuetz16-Feb-07 0:17
Stefan Troschuetz16-Feb-07 0:17 
AnswerRe: "interface and abstract" [modified] Pin
Parwej Ahamad16-Feb-07 0:22
professionalParwej Ahamad16-Feb-07 0:22 
GeneralRe: "interface and abstract" Pin
Daniel Turini16-Feb-07 5:54
Daniel Turini16-Feb-07 5:54 
GeneralRe: "interface and abstract" Pin
Parwej Ahamad16-Feb-07 7:10
professionalParwej Ahamad16-Feb-07 7:10 
GeneralRe: "interface and abstract" Pin
Daniel Turini19-Feb-07 11:46
Daniel Turini19-Feb-07 11:46 
AnswerRe: "interface and abstract" Pin
Michael Sync16-Feb-07 0:37
Michael Sync16-Feb-07 0:37 
AnswerRe: "interface and abstract" Pin
LogiPro10125-Jan-09 11:30
LogiPro10125-Jan-09 11:30 
Difference between Abstract classes and Interface
Little background:
A real world entity is represented in an OOP world as object. Objects are defined as classes any language.
A class defines objects in two aspects
Object's characteristics - Data Members
Object's functionality - Member functions

So, when the classes that are forced to provide implementations of the functions prototypes that are defined in either ‘interfaces’ or a ‘abstract class’ are not belonging to the same family (having some inherited parental characteristics from same parent directly or indirectly) but are rather related through some functionalities then 100% we will go with interface and if above said classes are belonging to same family then we should go with abstract class inheritance.
Also in case of inheritance as everything is a specialization of base parent object so there is allowance of providing some default definitions of the functions that are needed to be implemented further by specialized classes. This is not any way allowed in interfaces because implementing classes are not belonging to same family and are not any way related by characteristics.

An Example:
We have four real world objects:
• Airplane
• Bird
• Sparrow
• Eagle

We have one method that is a functionality of all above objects
• Fly

Now all objects share common functionality flying in air but differ in the mechanism they use to fly.

Also by close look we see that in general there is some common characteristics (as well as some common functionalities) between Sparrow and Eagle that can be a part of common class Bird (that has to be abstract because there is no real thing like bird!). But any way Airplane can't be related to Bird or its specialized classes Sparrow and Eagle.

So if want to expose fly functionality to outer world and want their implementations in Airplane and Sparrow (or any bird), so I will 100% go for Interface and Abstract classes will be a big NO!

But if we exclude Airplane want that fly functionality is exposed to outer world and its implementing classes are Bird, Sparrow and Eagle then 'Abstract Classes' is the best of best choice.

Happy programming! Please feel free in writing to me for further clarifications on other OOP concepts (im.himanshu2006@gmail.com)

Himanshu
Questionabout threading Pin
Abhishek Joshi15-Feb-07 23:48
Abhishek Joshi15-Feb-07 23:48 
AnswerRe: about threading Pin
Stefan Troschuetz16-Feb-07 0:13
Stefan Troschuetz16-Feb-07 0:13 
AnswerRe: about threading Pin
ednrgc16-Feb-07 8:10
ednrgc16-Feb-07 8:10 
GeneralRe: about threading Pin
Luc Pattyn16-Feb-07 9:57
sitebuilderLuc Pattyn16-Feb-07 9:57 
QuestionConvert Jpeg to Mime Pin
Russell Jones15-Feb-07 23:44
Russell Jones15-Feb-07 23:44 
Questionscripting client side Pin
kalyan_241615-Feb-07 22:22
kalyan_241615-Feb-07 22:22 
AnswerRe: scripting client side Pin
Sylvester george15-Feb-07 22:28
Sylvester george15-Feb-07 22:28 
GeneralRe: scripting client side Pin
kalyan_241616-Feb-07 16:46
kalyan_241616-Feb-07 16:46 
QuestionHow to write NUNIT Test Cases for Crystal Reports? Pin
Harshal Nemade15-Feb-07 22:14
Harshal Nemade15-Feb-07 22:14 
QuestionDetecting PC monitor going standby Pin
Xiao_M15-Feb-07 21:27
Xiao_M15-Feb-07 21:27 
AnswerRe: Detecting PC monitor going standby Pin
Thomas Stockwell16-Feb-07 6:19
professionalThomas Stockwell16-Feb-07 6:19 
QuestionExpression validator Pin
Sirisha.Konda15-Feb-07 21:13
Sirisha.Konda15-Feb-07 21:13 
AnswerRe: Expression validator Pin
ShermansLagoon16-Feb-07 0:11
ShermansLagoon16-Feb-07 0:11 
Questionbuffer notification points Pin
giltendezm15-Feb-07 20:56
giltendezm15-Feb-07 20:56 
QuestionMultiple clients Pin
Rahul.RK15-Feb-07 20:13
Rahul.RK15-Feb-07 20:13 
AnswerRe: Multiple clients Pin
Colin Angus Mackay15-Feb-07 23:09
Colin Angus Mackay15-Feb-07 23:09 
QuestionDisplaying files on the web page [modified] Pin
Sharon Alexander15-Feb-07 19:43
Sharon Alexander15-Feb-07 19:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.