Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Why Use Interfaces
Message
De
04/01/2008 09:40:11
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
 
 
À
03/01/2008 23:19:30
Information générale
Forum:
ASP.NET
Catégorie:
Conception classe
Divers
Thread ID:
01278205
Message ID:
01279433
Vues:
22
>I think it's different in this case. Have you ever seen a dotnet class that implements several interfaces? Or inherits from a class and implements an interface or 2?
>
>It has the possibility to make your app more robust and cleaner. For example you can define an interface that has some basic methods to deal with business classes. Just for grins it might have some basic save methods for backing up the data before your changes are made. Which can be used across multiple classes that have no real relationship. You will do the same algorithm for saving the data no matter what type of class it is.
>
>If you have an employee class, this can inherit from your base person class, and implement your interface with the basic save, etc., methods. You might have a job class, that inherits from another base class, but also implements the same interface.
>
>Because both classes implement the same interface, you are assured that no matter what the class is, you call the same methods to save.
>
>That's why you see interfaces such as ISerializable, ICloneable, etc. Use Interfaces for functions that will operate across disaparate classes.
>
>Use base classes to implement class functionality particular to that class, but interfaces to help define basic class functionality. Makes for a much more readable program.
>
>

Thanks Perry, this is what I was trying to demonstrate earlier. I just botched it with my example.
Tim
Timothy Bryan
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform