/* File: SerializationInterface.java CVS Info: $Id: SerializationInterface.java,v 1.2 1998/08/03 20:00:59 mcgredo Exp $ Compiler: jdk 1.3 */ package mil.navy.nps.dis; // our package name import java.io.*; /** * Defines interface methods governing object serialization. * *@version 1.0 *@author Don McGregor (http://www.npsnet.org/~mcgredo) * *
* *WHAT'S AN INTERFACE?
* * An interface defines a set of methods. Usually the set of methods * is related to some operation, such as drag and drop--the class must * implement several methods to fully implement the behavior, and the * method definitions need to be consistent across every class that * implements the behavior.
* * So what's the advantage to Interfaces over inheritence? After all, we * might create an abstract class, and have all the classes that inherit * from that class implement the set of methods defined in the interface. * The advantage is that interfaces don't have to be applied to classes * in the same class hierarchy. In our case, the serialization interface * is defined, and both the PduElement class tree and the Unsigned number * class tree implement the interface. These classes are related only in * that they have a common ancestor, which we can't modify, and probably * wouldn't want to anyway, since we would then have to implement the methods * for every intermediate class. Java doesn't do multiple inheritence * (thank the elder gods), so we can't do mix-ins.
* * By declaring that a class implements an interface, we can make compile-time * checks to confirm that the class does indeed have the correct method * prototypes. Interfaces are also useful for determining at runtime whether * a class can perform the operations required to implement a behavior.
* *