Video summary

UML Class Diagram Tutorial

Main summary

Key takeaways

Educational

Main Ideas and Concepts

  • Purpose of UML Class Diagrams

    • Used to model a system by describing the things in the system as classes, and how those classes relate.
  • Core Structure of a Class Diagram

    • A class is drawn with a standard UML class box.
    • The box is divided into sections:
      • Top section: the class name
        • Example: Animal
      • Middle section: attributes (significant data describing instances)
        • Also known as: fields, variables, or properties
        • Example attributes for Animal: name, ID, age
      • Bottom section: methods (behavioral features)
        • Also described as operations or functions
        • Example methods for Animal: Set Name, eat

Attribute Formatting

Attributes must follow this notation pattern:

  • Start with a visibility symbol
  • Attribute name begins with a lowercase letter
  • Then a colon
  • Then the data type

Example (conceptually):

  • - name: string
  • - id: integer

Method Formatting

Methods must follow this notation pattern:

  • Start with a visibility symbol
  • Method name begins with a lowercase letter
  • Use parentheses to indicate the function
  • Optionally include parameters and data types (often omitted in examples)

Example:

  • + eat()

Visibility (Accessibility) Rules

  • Private: -
    • Only accessible within the class (not by other classes or subclasses)
  • Public: +
    • Accessible by any other class
  • Protected: #
    • Accessible within the class and its subclasses
  • Package/default: ~ (rarely used)
    • Accessible by other classes in the same package

Relationships Between Classes

The video covers several UML relationship types, using zoo examples first and then an online shopping cart example.

Methodology / Instructions (Explicit Rules and Steps)

A) Creating a Class in UML

  1. Choose a class name and place it in the top section.
  2. Add attributes in the middle section using:
    • visibility symbol + lowercase attribute name + colon + data type
  3. Add methods in the bottom section using:
    • visibility symbol + lowercase method name + parentheses
    • Optionally add parameters and their types.

B) Setting Up Visibility for Attributes and Methods

Use:

  • - for private
  • + for public
  • # for protected
  • ~ for package/default

C) Modeling Class Relationships

Inheritance

  • Draw open arrows from child classes to the parent/superclass.
  • Subclasses inherit attributes/methods from the superclass.
  • Terms child/parent describe roles.
  • Abstract class:
    • Indicated by putting the class name in italics
    • Conceptually, it isn’t instantiated directly.

Association

  • Draw a simple line between related classes.
  • Example meaning: “Otter eats Sea Urchin.”

Aggregation

  • A special form of association showing whole vs. parts where:
    • Parts can exist independently of the whole.
  • Notation: open diamond

Composition

  • Another whole/part relationship where:
    • Parts cannot exist without the whole.
  • Notation: closed diamond

Multiplicity

  • Add numerical constraints to relationship ends.
  • Examples:

    • 1 = one and only one
    • 1..* = one or more (implied “one or many”)
    • 0..1 = optional
    • 0..* = zero or many
    • 1..* = one or many
    • A specific range = written in range format (generalized in the video)
    • N = an exact specific number

Examples Used to Reinforce Concepts

Zoo Example (Classes + Inheritance/Abstraction + Relationships)

  • Classes: Animal, with subclasses Tortoise, Otter, Slow Loris
  • Inheritance: subclasses inherit name, ID, age from Animal
  • Abstract class concept: Animal is abstract (not instantiated directly)
  • Association: Otter associated with Sea Urchin (e.g., “Otter eats Sea Urchin”)
  • Aggregation: Creep (a group of tortoises) relates to Tortoise
    • Tortoise can leave the creep and still exist independently
  • Composition: Visitor Center contains Lobby and Bathroom
    • If a visitor center is destroyed, lobby and bathroom are destroyed too
  • Multiplicity:
    • e.g., 1 lobby per visitor center
    • bathrooms could be one or many (flexible upper limit)

Real-World Example: Online Shopping Cart

  • User class

    • Attributes: user ID, password, login status, register date
    • Methods: verify login() returning boolean
  • Inheritance

    • Customer and Administrator inherit from User
    • They also have their own additional behaviors/attributes
  • Composition

    • Customer “contains”/owns shopping cart and related parts
    • Cart destroyed if customer destroyed
    • Shipping Info and Order Details depend on Order existing
  • Multiplicity

    • Customer ↔ Orders: customer can have zero or many orders
    • Order ↔ Customer: each order belongs to only one customer
    • Order ↔ Order Details: one-to-one (one and only one on both ends)

Speakers / Sources Featured

  • Zach (host/instructor), “Zach, and I’m with Lucidchart”
  • Lucidchart (diagramming software referenced and promoted)

Original video