It's like anything else in the art of software design -- it depends. It depends on what you are trying to do, what the project goals are, and what trade-offs you you need to make -- there are guidelines, but very few hard rules.
In general, an abstract class (or base class) is a good solution for objects that are very similar, and could potentially re-use the same code throughout good chunks of each class. Think of classes like the web controls (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebuiwebcontrolswebcontrolclasshierarchy.asp) in the .NET framework, text box, list control, etc. all derive from the same base class. While their behaviors are very different at a superficial level, they share many common properties and methods. An interface is a good solution when a number of disparate objects need to share the same interface, but will have very different implementations, or similarly when an object needs to display many different sets of behaviors, but can only inherit a single base class. The ISerializable interface (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemruntimeserializationiserializableclasstopic.asp) is an excellent example. This is an interface that will be used by many objects, but will be implemented in many ways. A good guide is to search through the .NET framework and see which classes have been implemented using base classes and how interfaces are used. Also check out Head First Design Patterns (http://www.amazon.com/exec/obidos/tg/detail/-/0596007124/qid=1118601198/sr=8-1/ref=pd_csp_1/102-6505139-8209727?v=glance&s=books&n=507846), it's based on Java, but provides excellent real world examples of how to incorporate OOD into your software design. On 6/12/05, Arindam <[EMAIL PROTECTED]> wrote: > > Hi Champs, > I am new in .net developing, > Recently i have completed one project, where i developed > a class library,so i've played with class little bit, > > Now i want use Interface , > common features of Interface i know, > like multiple inheritence possible with Interface , which is not possible > with class in C#. > > But again it's not very clear to me, > can someone explain me where should i use interface not class ? > > i will b greatfull. > > Thanks > Arindam > > > > Thanks & Regards > > Arindam > Web Designer & Developer > > > > > > --------------------------------- > Too much spam in your inbox? Yahoo! Mail gives you the best spam protection > for FREE! > http://in.mail.yahoo.com > > [Non-text portions of this message have been removed] > > > > > Yahoo! Groups Links > > > > > > > -- Dean Fiala Very Practical Software, Inc http://www.vpsw.com Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
