Chapter 18. UML Basics
Unified Modeling Language (UML) is an object modeling specification language that uses graphical notation to create an abstract model of a system. The Object Management Group (http://www.uml.org/) governs UML. This modeling language can be applied to Java programs to help graphically depict such things as class relationships and sequence diagrams. Comprehensive information on UML is covered in UML Distilled, Third Edition, by Martin Fowler (Addison-Wesley Professional, September 2003).
Class Diagrams
A class diagram represents the static structure of a system, displaying information for classes and relationships between them. The individual class diagram is divided into three compartments: name, attributes (optional), and operations (optional); see Figure 18-1 and the example that follows it.
// Corresponding code segment class Orchestra { // Class Name // Attributes private String orch Name; private Integer instrCount = 7; // Operations public void setOrchName(String name) {...} public Boolean play(Score s) {...} }
Name
The name compartment is required and includes the class or interface name typed in boldface.
Attributes
The attributes compartment is optional and includes member variables that represent the state of the object. The complete UML usage is as follows:
visibility name : type [multiplicity] = defaultValue {property-string}
Get Java Pocket Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.