UML 2 Interface Style Guidelines

Scott W. Ambler
 
   Home  |  AMDD  |  Best Practices  |  Architecture  |  Requirements  |  Analysis  |  Design  |  Documentation  |  Models  |  Modeling Style  |  Contact Us  |  Mailing List  |  FAQ
Elements of UML 2.0 Style An interface is a collection of operation signatures and/or attribute definitions that ideally defines a cohesive set of behaviors.  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.

 

  1. Depict One Interface Per PortPorts 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.
  2. 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.
  3. Provided Interfaces on the Left. In Figure 1 the provided interfaces are depicted using “lollipop” notation.
  4. Required Interfaces on the Right. Required interfaces, such as Student, Persistence, and XMLProcessor in Figure 1 are depicted in UML 2 as “sockets”. 
  5. Apply Realizes Relationships for Ports.  In Figure 1 SeminarComponent realizes the three ports on the left of the frame and the Enrollment class delegates to the Student port.
  6. 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. 
  7. Name Interfaces According to Language Naming Conventions.
  8. Prefer “Lollipop” Notation to 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. 
  9. Define Interfaces Separately from Your Classifiers.
  10. Do Not Depict the Operations and Attributes of Interfaces in Your Classes.
  11. 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. 
  12. Place Interface Labels Above The Interface.

 

Recommended Resources

Elements of UML 2.0 Style   The Elements of UML 2.0 Style describes a collection of standards, conventions, and guidelines for creating effective UML diagrams. They are based on sound, proven software engineering principles that lead to diagrams that are easier to understand and work with.  These conventions exist as a collection of simple, concise guidelines that if applied consistently, represent an important first step in increasing your productivity as a modeler.  This book is oriented towards intermediate to advanced UML modelers, although there are numerous examples throughout the book it would not be a good way to learn the UML (instead, consider The Object Primer).  The book is a brief 188 pages long and is conveniently pocket-sized so it's easy to carry around.
The Object Primer 3rd Edition: Agile Model Driven Development (AMDD) with UML 2   The Object Primer 3rd Edition: Agile Model Driven Development with UML 2 is an important reference book for agile modelers, describing how to develop 35 types of agile models including all 13 UML 2 diagrams.  Furthermore, this book describes the techniques of the Full Lifecycle Object Oriented Testing (FLOOT) methodology to give you the fundamental testing skills which you require to succeed at agile software development.  The book also shows how to move from your agile models to source code (Java examples are provided) as well as how to succeed at implementation techniques such as refactoring and test-driven development (TDD).  The Object Primer also includes a chapter overviewing the critical database development techniques (database refactoring, object/relational mapping, legacy analysis, and database access coding) from my award-winning Agile Database Techniques book.
Agile Modeling   Agile Modeling: Effective Practices for Extreme Programming and the Unified Process is the seminal book describing how agile software developers approach modeling and documentation.  It describes principles and practices which you can tailor into your existing software process, such as XP, the Rational Unified Process (RUP), or the Agile Unified Process (AUP), to streamline your modeling and documentation efforts.  Modeling and documentation are important aspects of any software project, including agile projects, and this book describes in detail how to elicit requirements, architect, and then design your system in an agile manner.

 

 

Let Me Help

I actively work with clients around the world to improve their information technology (IT) practices as both a mentor/coach and trainer.  A full description of what I do, and how to contact me, can be found here

 


Copyright © 2004-2007 Scott W. Ambler


This site owned by
Ambysoft Inc.

Agile Data (AD)  |  Agile Unified Process (AUP)  |  Enterprise Unified Process (EUP)  |  My Writings