## The Unified Markup Language (UML)

UML Examples

The Unified Modeling Language (UML) is a standardized way of specifying, visualizing, and documenting the artifacts of an object-oriented software under development (among other things).

To visualize classes and objects and their relationships in this -- a first course in Java -- we will use some of the features of these diagrams. Although, you should know that UML can do much more than just that.

Indeed, UML 2.2 has 14 types of different diagrams, half of which represent structural information, while the other half represent general types of behavior and interactions. Class diagrams and Object Diagrams are but two of the "structure diagrams" that exist.

14 Different Types of Diagrams

### Class Diagrams

In UML, one represents a class with a box that has 3 sections: The top section displays the class name, the middle section displays the instance variables of that class, and the bottom section displays its methods. For example, a UML class diagram for a BankAccount class might look like the following:

As can be seen above, we specify the visibility of class members (any data fields, constructors, or methods) by putting the following notations before each member's name:

+          Public
-          Private
#          Protected
~          Package (default visibility)


Other properties of class members, we can indicate with the format of the text:

underline  static
italic     abstract
all-caps   constants


Note in UML, the return type of a method comes AFTER the parameter list for the method, with the two separated by a colon (":").

UML object diagrams are similarly constructed, except they only show the state of the object as determined by its data fields. For example, two objects of type BankAccount are shown below in UML style:

We use (open triangle tipped) arrows to denote subclass relationships. In UML, the arrow points from the subclass to its related superclass.

So for example, if we wanted to describe the class GeometricObject, and two of its subclasses, Circle and Rectangle, we might see something like the following in UML: