Object-Oriented Programming

UML Class Design

Michael L. Collard, Ph.D.

Department of Computer Science, The University of Akron

Communicating Class Design

  • Textual description
  • C++ code
  • UML Class

UML in Brief

  • Unified Modeling Language
  • Grady Booch, Ivar Jacobson, and James Rumbaugh
  • Standardized, general-purpose, modeling language
  • Purpose: visualize, specify, construct, and document artifacts of software systems
  • Very different from software programming languages such as Python, C, C++, etc.
  • Pictorial language to generate powerful modeling elements.
  • Highly related to object-oriented analysis and object-oriented design
  • Has applications outside the software industry

UML Diagrams

UML Class

  • A static, structure diagram
  • Name
  • Attributes - data members, fields
  • Operations - methods, member functions

Partial Meta-Object Facility (MOF)

Level Name Description Example
M2 metamodel UML Syntax Cat
M1 model UML Model
M0 data layer Real World Cat

Role of Classes

  • Classes represent the parts of the program
    • They are entities, not actions
    • PascalCase, e.g., Project, UndergraduateStudent
  • Operations are the actions of the class
    • Like free functions, they are in the verbTarget form
    • camelCase typically used (at model level)

Multiple Views


  • + public
  • - private
  • # protected
  • ~ package

UML Primitive Types

  • Integer
  • UnlimitedNatural
  • Real
  • Boolean
  • String

Attributes: visibility name:type multiplicity = default {property-string}

Attribute Syntax Description
+name public name
-name private name
-name:Name private name of type Name
-name:Name = "Project" private name of type Name with default “Project”
-name:Name[3] private name of type Name with multiplicity of 3
-name:Name = "Project" { persistent } private name of type Name with default “Project”, and property ‘persistent’

Operations: visibility name(parameter-list):return-type {property-string}

Operator Syntax Description
+draw() public operator draw()
-draw() private operator draw()
#draw() protected operator draw()
+draw() : Boolean public operator draw() with return type Boolean
+draw() : Boolean {optional} public operator draw() with return type Boolean, and a property optional

Operation Parameters: direction name:type = default

Parameter Syntax Description
+draw(: Shape) parameter of type Shape
+draw(s: Shape) parameter s of type Shape
+draw(in shape : Shape) in parameter shape of type Shape
+draw(out picture : Picture) out parameter picture of type Picture
+draw(inout picture : Picture) inout parameter picture of type Picture

Directions: in, out, inout

Parameter Directions in C++

C++ Declaration UML Parameter Direction
Shape in
const Shape& in
const Shape* in
Shape& inout
Shape* inout
Shape** out (typical API usage)



Multiplicity Syntax Description
* Any number of values
1 Single value (default)
0..1 No more than a single value
2..4 Two to four values

Multiplicity Terms

Multiplicity Term Description
Optional *
Mandatory 1..*
Single-valued 0..1
Multivalued 0..2, 0..*

Mapping Multiplicity to C++

  • Multivalued
    • std::vector<int>, std::deque<int>, std::list<int>, std::array<int, n>
  • Single-valued
    • std::optional<int> - C++14


  • stereotype is an extension mechanism to UML used as part of profiles
  • keyword is a formally defined stereotype
  • CBE - Control, Boundary, Entity


  • Use text to clarify diagram/design
  • The UML “comment” mechanism
  • No formal definition of note content


  • Attributes show the state of the objects and may not map directly into types in the implementation language
  • Show only the attributes and operations (methods) important for the given purpose
  • Public attributes typically map to get and set (stereotype) methods in the code
  • Only display constructors if needed

Forward Engineering

Reverse Engineering

UmlMode [Fowler]


  • UML to communicate an aspect of a system
  • forward engineering - sketches to work out design before implementation
  • reverse engineering - sketches for comprehension
  • Main feature: Selectivity
  • Requirements: Need to be performed quickly and collaboratively using whiteboard or paper


  • Express design enough to hand off to another group
  • forward engineering - Every detail needed to implement the design
  • reverse engineering - Every detail of what design is in the code
  • Separation of labor: High-end designers versus “coders”
  • Main feature: Completeness


Current View

And, IMHO, the UML standard starting going off the rails when some started morphing it to be a programming language with formal semantics. Visual representations are by their very nature abstractions, not precise representations.

Grady Booch (@Grady_Booch) June 30, 2018