A UML interface is a collection of operation signatures and/or attribute definitions that ideally defines a cohesive set of behaviours. UML interfaces are implemented, “realized” in UML parlance, by classes and components – to realize an interface, a class or component must implement the operations and attributes defined by the interface. Any given class or component may implement zero or more interfaces, and one or more classes or components can implement the same interface.Figure 1. The internals of the seminar component.
Figure 2. Class implementing interfaces.
Figure 3. Logical component architecture.
Depict One Interface Per Port. Ports are connection points between a classifier and its environment that are depicted on the side of frames as small rectangles. In Figure 1 each port has exactly one interface, which is logically cohesive and thus does not reveal anything about the internal design of the Seminar component.
Depict One Port Per Realizing Class. Another approach to organizing the interfaces for SeminarComponent of Figure 1 would be to have a single port offering the Enrollment, Transcript, and DataEntity interfaces. This would make for a more compact diagram although contradicts Depict One Interface Per Port: choose an approach and stick to it.
Provided Interfaces on the Left. In Figure 1 the provided interfaces are depicted using “lollipop” notation.
Required Interfaces on the Right. Required interfaces, such as Student, Persistence, and XMLProcessor in Figure 1 are depicted in UML 2 as “sockets”.
Apply Realizes Relationships for Ports. In Figure 1SeminarComponent realizes the three ports on the left of the frame and the Enrollment class delegates to the Student port.
Reflect Implementation Language Constraints in Interface Definitions. In Figure 2, the interface includes a public attribute named POID and several public operations. Unfortunately, it could not be implemented in Java because this language does not (yet) support instance attributes in the definition of interfaces.
Name Interfaces According to Language Naming Conventions .
Prefer “Lollipop” Notationto Indicate Realization of an Interface. As you can see in Figure 2 there are two ways to indicate that a class or component implements an interface: the lollipop notation used with the Serializable interface and the realization line (the dashed line with a closed arrowhead) used with the PersistentObject interface.
Define Interfaces Separately from Your Classifiers.
Do Not Depict the Operations and Attributes of Interfaces in Your Classes.
One Label Per Interface Connection. In Figure 3 you see that the IPersistence interface is indicated twice, once for the lollipop and once for the socket.