A UML class represents a class. This could be a class of analysis objects, a design-time class, or an implementation class (Java, C++, C#, etc.)
A UML class icon has three compartments:
The top compartment contains the name of the class and its optional stereotype.
A stereotype can be used to show an informal role or category of a class.
In an analysis model typical stereotypes are:
<<entity>> = a domain-specific object such as a bank account or employee
<<control>> = an object that excutes user commands
<<boundary>> = an interface between an actor and a control. A control panel, for example.
<<actor>> = a person, device, or server that interacts with a system
Entity classes can be further subdivided into:
<<thing>> = an entity that has mass and volume
<<event>> = an entity that has a start time and duration
<<role>> = an entity that executes tasks. For example: plumber, clerk, nurse
<<type>> = an entity that describes other entities: film genre (Sci Fi, comedy, etc.), film rating (P, PG, etc.)
A well known design-time stereotype:
<<interface>> = a collection of related operations that must be implemented
The middle compartment contains the attributes all instances of a class will have.
An attribute has four properties:
name
type (this can be a primitive type such as int, boolean, or double or an external class such as String or Money)
visibility (+ = public = system visibility, ~ = package visibility, # = protected = sub-class visibility, - = private = class visibility)
initial value
The third compartment contains the operations that instances of the class can execute.
Note that an operation is a method without an implementation:
method = operation + implementation
An operation has four properties:
name
scope (same as above)
parameters (each parameter has a name and type)
return type (usually supressed if void)
An object icon has the form:
Note that the attribute-value compartment and name are optional.
For example:
Note that the operations are not shown. This would be tiresome since the operations are the same for all instances of a class.
A package icon is a folder:
For example, most of the Java class library is contained in the java package:
This package contains sub-packages such as:
In addition to libraries, packages often contain models:
And sub-systems:
A note is the UML equivalent of a comment: