Analiza și Modelarea Sistemelor Software - Lecture 2: UML Class Diagrams

Traian-Florin Șerbănuță

2025

Agenda

  1. Quick recap
  2. What are class diagrams?
  3. Core elements of class diagrams
  4. Associations, multiplicity & composition
  5. Advanced concepts (generalization, interfaces, dependencies)
  6. Interactive exercise 1: Identify model elements
  7. Design heuristics and good practices
  8. Interactive exercise 2: Build a small class model
  9. Wrap-up & next steps

Recap from Last Class

Today: move from informal to formal models.

What is a Class Diagram?

Sample class diagram

Order processing
Order processing

Core Elements

Concept Description Example
Class Blueprint for objects Book, Student
Attribute Property of a class title: String, age: Integer
Operation Behavior of a class borrowBook(), calculateFine()
Visibility Access modifier + public
- private
# protected
~ package

Attribute ::= visibility name: type multiplicity = default {props}

Operation ::= visibility name(parameter-list): return-type {props}

Parameter ::= direction name: type = default_value

Associations

Properties vs Associations:

Properties
Properties
Associations
Associations

Bidirectional Associations

A bidirectional association
A bidirectional association

If I start with a car, take its owner, then take the cars property of the owner, then I should find the original car among those cars.

Another way to show a bidirectional association
Another way to show a bidirectional association

Aggregation vs Composition

Generalization and Interfaces

Dependencies

Example – Interfaces and abstract classes in Java

Interfaces and abstract classes in Java – expanded view
Interfaces and abstract classes in Java – expanded view
Interfaces and abstract classes in Java – ball-and-socket view
Interfaces and abstract classes in Java – ball-and-socket view

Interactive Exercise 1: Spot the Elements

Class: Library
 - name: String
 - books: List<Book>
 + addBook(b: Book)
 + findBook(title: String): Book

Class: Book
 - title: String
 - author: String
 + borrow()
 + return()

Task (5 minutes): Identify classes, attributes, operations, and their relationships.

Design Heuristics & Good Practices

Example – over-complicated diagram

Example – Simplified (conceptual) diagram

Interactive Exercise 2: Build a Class Diagram

Scenario: Online food delivery system.

Task (15 minutes):

Then: Present and discuss different design choices.

Wrap-Up

Today’s takeaways:

Next class: requirements analysis