Articles
Bala Paranj

How to Find Interfaces in a System

Articles by Bala Paranj


Interfaces offer flexibility. The degree of flexibility is determined by the requirements. This flexibility could be the ease of replacement of an external system, for instance credit card processing system. This type of plug and play is called as a "seam" in UML.

How do Interfaces differ from abstract classes? They do not force any structural relationship between two entities. For example you can have a Singable interface which is implemented by a Person class, a Toy class and so on, none of the classes which implement this interfaces are related to each other.

Whereas if you use abstract class lets say Sing class and the extend this in the Person and Toy class, it means you are saying that Person class and Toy class share certain attributes and behavior which is absurd.

When should we use interfaces and abstract classes? One of the questions that you must answer is "When is it appropriate to use inheritance?" This question is answered very well in Peter Coad's book as well as the OOAD with UML Study Guide tips section (which is very exhaustive).

In a nutshell: Abstract classes make sense when you want implementation inheritance. Interfaces are for interface inheritance.

Note that once you publish your interface, if you change it later, you will break all your clients. This is not the case in abstract classes.

If you use interfaces everywhere blindly you will end up in a system which is slow and complex. It must be used at "hot spots" of the system. Hot spots are the places where you need extensibility, plug and play and no structural constraint on the inheritance hierarchy.

I have only discussed some of issues related to interfaces. Look in the links section of the OOAD_UML yahoo group for the Java World Article by Bill Venners. This is a good article for beginners to understand interfaces.

Reference: Read the Java Design - Building Better Apps & Applets by Peter Coad & M. Mayfield for an excellent discussion on this topic.

OOAD skills for the real world projects

Study Guide - Object Oriented Analysis and Design with UML

 

   
© 2004 www.zepho.com All Rights Reserved.