Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Interfaces Question
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
01097322
Message ID:
01097325
Vues:
11
Hi, Shawn,

When I first looked at interfaces, I had the same types of questions.

Remoting is a good example of how interfaces can help. Let's say you have one set of classes (in domain 'A') that work with another set of classes (in a different domain, domain 'B') via remoting. The project for domain 'A' doesn't have the code for domain 'B'...but domain 'A' can work with domain 'B' through an interface.

Domain 'B' might have a method called GetOrders. It receives a customer ID as a parameter, and returns an XML string representing all the orders. You can define an interface so that domain 'A' can instantiate the classes in domain 'B' via a remoting object, and then cast the object to the interface, which defines the method for GetOrders.

So again, while domain 'A' doesn't have the assemblies for domain 'B', you can code against the interface, get the strong-typing in intellisense (since the interface defines the parameters received and returned).

Another example is generic data binding. Each winforms control handles data binding a little differently (comboboxes, textboxes, etc.) You can set up a binding interface called IBinding, with a method called BindControl. Each winform control class that you define can implement IBinding, and can have a method called BindControl. Now....each control might do it differently - but you've established a "contract" that each control will the same method.

My article in the July/August 2005 issue of CoDe Magazine covers these.
http://www.code-magazine.com/Article.aspx?quickid=0507031

Kevin
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform