-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: KartikKrish
Message 3 in Discussion


use 
interface when you want  to implement the details independently in 
individual classes.Use abstract class when u want to implement a base 
functionality in an abstract class and then u want to override virtual methods 
in your derived classes.One advantage is that basic validation can be done by 
the abstract class
Eg-say 

Manager dervies from Employee
 
when u 
say
 
Manager manager = new Manager(null); (where the parameter is the 
name)
 
u can 
then specify in your manager class as
 
public 
Manager{
public 
Manager(string name) : base(name)
{
}
}
 
public 
class Employee
{
public 
Employee(string name)
{
if(name == null !! Trim(name.Length) ==0)
{
    throw Exception("Name cant be null");
}
}
 
From 
this u can see that this can be used for all child classes deriving from 
Emplyee
 
Further,any new methods added to the base class are inherited for 
free(public and protected methods), with NO recompilation reqd. It is clear 
that 
in an interface this is required
 
Most 
importantly,from a modeling viewpoint
 
abstract class represents an is-a relationship (generalization) where as 
an interface represents a realization.
 
Karthik

  
  -----Original Message-----
From: kals_j 
  [mailto:[EMAIL PROTECTED] 
Sent: Monday, December 20, 2004 12:24 
  PM
To: BDOTNET
Subject: Interface and 
  Abstract


  
    
      
      New Message on BDOTNET
    
      

  Interface 
    and Abstract


    
      
      
        Reply

        
          
            
            
               
              Reply to Sender   Recommend 
              Message 1 in 
                Discussion 
      
        
          
            
            
              From: kals_j 
            
              

                Anyone tell me the best scenario to go for Interface and 
                Abstract instead of going normal class...?
                 
                Kals
View other groups in this 
    category. 



-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member 
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you 
received this message by mistake, please click the "Remove" link below. On the 
pre-addressed e-mail message that opens, simply click "Send". Your e-mail 
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to