Interface-Based Programming

Interface-Based ProgrammingShort Description
As explained in Chapter 1, separation of interface from implementation is a core principle of component-oriented programming. When you separate interface from implementation, the client is coded against an abstraction of a service (the interface), not a particular implementation of it (the object). As a result, changing an implementation detail on the server side (or even switching to a different service provider altogether) doesn’t affect the client. This chapter starts by presenting .NET interfaces and describing what options are available to .NET developers when it comes to enforcing the separation of interface from implementation. It then addresses a set of practical issues involving the definition and use of interfaces, such as how to implement multiple interfaces and how to combine interfaces and class hierarchies. After a detailed look at generic interfaces, the chapter ends with a discussion of interface design and factoring guidelines.

Website: www.oreilly.com.cn | Filesize: 979kb
No of Page(s): 36

Content

In traditional object-oriented programming, you typically use an abstract class to define a service abstraction. The abstract class serves to define a set of signatures that multiple classes will implement after deriving from the abstract class. When different service providers share a common base class, they all become polymorphic with that service abstraction, and the client can potentially switch between providers with minimum changes. There are a few important differences between an abstract class and an interface:
• An abstract class can still have implementation: it can have member variables or non-abstract methods or properties. An interface can’t have implementation or member variables.
• A .NET class can derive from only one base class, even if that base class is abstract. However, a .NET class can implement as many interfaces as required.
• An abstract class can derive from any other class or from one or more interfaces. An interface can derive only from other interfaces.
• An abstract class can have nonpublic (protected or private) methods and properties, even if they are all abstract. In an interface, by definition, all members are public.
• An abstract class can have static methods and static members and can define constants. An interface can have none of those.
• An abstract class can have constructors. An interface can’t.

Get the file Download here

AddThis Social Bookmark Button
Related Books:
  • SAP Interface Programming
  • The MPI-Delphi Interface A Visual Programming Environment for …
  • Introduction to Programming In Java Programming In …
  • AVR910 In-System Programming
  • Basics of GPU-Based Programming
  • Jaxcent AJAX programming in Java alone
  • Aspect-Oriented Programming with C# and .NET
  • Chapter III Instructions and assembly programming

  • Related Searches: , , , ,



    Comments

    Leave a Reply