June 7, 2002 - The Interface's Advantages
June 7, 2002 The Interface's Advantages Tips: June 2002
Yehuda Shiran, Ph.D.
|
By itself, interfaces are not very useful. You cannot create instances of interfaces. You can implement interfaces by useful classes from which you can create instances. Interfaces are instrumental in enforcing object oriented design methodologies. One group may specify the interface for other groups to follow. Each group may implement its own function bodies, but all groups will adhere to the same interface, defined a priori. It comes back to the first and foremost incentive for object oriented programming: encapsulation. You don't care how a capability is implemented. You, as a programmer, are exposed only to the interface. This is also a good way to watch after the system architecture. You don't let everyone on the team define his or her own interfaces. One central group will usually define them for the rest. Interfaces are a good way to define methods for the whole project.
To learn more about JScript .NET, go to Column 110, JScript .NET, Part IV: Inheritance.