UML Tutorial – Class Diagrams

Categories:

Recommended

Introduction

UML stands for Unified Modeling Language. It represents a unification of the concepts and notations presented by the three amigos in their respective books1. The goal is for UML to become a common language for creating models of object-oriented computer software. In its current form, UML is comprised of two major components: a Meta-model and a notation. In the future, some form of method or process may also be added to; or associated with, UML.

The Meta-model

UML is unique in that it has a standard data representation. This representation is called the metamodel. The meta-model is a description of UML in UML. It describes the objects, attributes, and relationships necessary to represent the concepts of UML within a software application. This provides CASE manufacturers with a standard and unambiguous way to represent UML models. Hopefully, it will allow for easy transport of UML models between tools. It may also make it easier to write ancillary tools for browsing, summarizing, and modifying UML models. A deeper discussion of the metamodel is beyond the scope of this column. Interested readers can learn more about it by downloading the UML documents from the rational web site2.

The Notation

The UML notation is rich and full-bodied. It is comprised of two major subdivisions. There is a notation for modeling the static elements of a design such as classes, attributes, and relationships. There is also a notation for modeling the dynamic elements of a design such as objects, messages, and finite state machines. In this article, we will present some of the aspects of static modeling notation. Static models are presented in diagrams called: Class Diagrams.

Class Diagrams

The purpose of a class diagram is to depict the classes within a model. In an object-oriented application, classes have attributes (member variables), operations (member functions), and relationships with other classes. The UML class diagram can depict all these things quite easily. The fundamental element of the class diagram is an icon that represents a class.

A class icon is simply a rectangle divided into three compartments. The topmost compartment contains the name of the class. The middle compartment contains a list of attributes (member variables), and the bottom compartment contains a list of operations (member functions). In many diagrams, the bottom two compartments are omitted. Even when they are present, they typically do not show every attribute and operation. The goal is to show only those attributes and operations that are useful for the particular diagram.

This ability to abbreviate an icon is one of the hallmarks of UML. Each diagram has a particular purpose. That purpose may be to highlight a particular part of the system, or it may be to illuminate the system in general. The class icons in such diagrams are abbreviated as necessary. There is typically never a need to show every attribute and operation of a class on any diagram. Figure 2 shows a typical UML description of a class that represents a circle.

Notice that each member variable is followed by a colon and by the type of the variable. If the type is redundant, or otherwise unnecessary, it can be omitted. Notice also that the return values follow the member functions in a similar fashion. Again, these can be omitted. Finally, notice that the member function arguments are just types. I could have named them too, and used colons to separate them from their types, or I could have omitted the arguments altogether.

 

Category:
Tag:

Attribution

Robert C. Martin. UML Tutorial:
Part 1 — Class Diagrams. http://bluehawk.monmouth.edu/~jwang/umlClassDiagrams.pdf

VP Flipbook Maker

This flipbook was made with the free flipbook maker from Visual Paradigm Online, you can also develop a book like this. Create online flipbooks, design, publish and share your flipbooks online, try it now!