|
Use Abstract Base Classes With Web Services You can use both interfaces and abstract base classes to accomplish the same goals. (Old-timers might recall that the C++/COM language binding actually used abstract base classes to define interfaces.) The classic definition of an interface is a contract that specifies a class's publicly visible methods and properties, without regard to a specific implementation of the contract. Abstract base classes also define this kind of contract, but they're allowed (though not required) to specify an implementation for parts of the contract. Interface-based programming has become quite popular in recent years; however, Web services pose a challenge, because interfaces can't be serialized or deserialized as Web services parameters. You can use abstract base classes with Web services, so consider using them in Web services projects, instead of interfaces. This article's sample code uses this technique. |