Depicting Interfaces in UML

   

Figure 9.1 shows the relationships between the Sellable interface and its two implementations . Notice that interfaces in UML can be depicted in two different ways in a class diagram. The Sellable interface is shown very much like a class description with only the addition of the <<Interface>> stereotype to differentiate it. This form is useful when you want to include the details of an interface contract. As a slight change to our earlier example, the JavaBook class is also shown to implement the Cloneable interface. This interface is shown using a notation that does not include any details of the interface. This form is appropriate when the interface details are not needed to convey information about the class design. For example, marker interfaces and interfaces that are part of the Java API are good candidates for this notation.

You can see in Figure 9.1 that it is not necessary to list the getDescription, getUnits, getPricePerUnit, and getWeight methods in the class entries for Boeing767 and JavaBook. The indication that they implement the Sellable interface is sufficient information to let a reader know that these methods must be implemented in these classes. The notation used to show the interface dependencies mirrors that of an inheritance relationship in this diagram. Interface implementation is often indicated with a dashed line rather than a solid one to emphasize the difference.

Figure 9.1. A class diagram depicts common behavior defined through interfaces.

graphics/09fig01.gif

See "OOP and the UML,"

   


Special Edition Using Java 2 Standard Edition
Special Edition Using Java 2, Standard Edition (Special Edition Using...)
ISBN: 0789724685
EAN: 2147483647
Year: 1999
Pages: 353

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net