Figure A.1 applies some of the UML features for illustrating classes.
Figure A.1. Classes. Note that there is no guarantee that a UML diagram portrays every element of a package or class. The amount of detail in a diagram depends on the objective of the illustrator.
In Figure A.1, note the following.
A package appears as the name of the package in a rectangle left-aligned with a larger box that may show classes and interfaces. Figure A.1 shows a portion of the sjm.parse package.
A class appears as the name of a class centered in a rectangle. Figure A.1 shows three classes: Assembler , Assembly , and Repetition .
A diagram may show a class's instance variables and methods in rectangles beneath the class name. Class Repetition has an instance variable subparser , of type Parser . This class also has (at least) one constructor and (at least) one method, match() .
Instance variable declarations appear as the name of the variable followed by a colon and the type of the variable, as in subparser:Parser .
Variables in method signatures also appear as the name of the variable followed by a colon and the type of the variable.
A diagram that shows a method such as match() may also show the method's signature in the parentheses after the name. A colon and the return type of the method may follow this.
A class diagram may indicate that an instance variable or a method is protected by preceding it with a pound sign ( # ). A plus sign ( + ) indicates that a variable or method is public.
A diagram may indicate that an instance variable is static (and thus has class scope) by underlining it. (Figure A.1 does not show this feature.)