Week 5 notes
Class Diagrams Overview
Definition: A UML diagram that outlines objects and their relationships in a system.
Purpose:
Helps in understanding and planning the system.
Acts as a technical communication document between teams.
Illustrates data models for information systems.
Helps coordinate a long-term system vision.
2. Class Diagram Structure
Basic Elements:
Class Name
Attributes (characteristics of the class)
Methods (Operations) (functions performed by the class)
Object vs. Class:
Class: A logical group of objects with common attributes, relationships, and behaviors.
Object: An instance of a class with a defined role, state, behavior, and unique identity.
3. Operations in Class Diagrams
Definition: Functions or services provided by all instances of a class.
Types:
Constructor – Creates a new instance of a class.
Query – Accesses an object’s state without modifying it.
Update – Alters an object’s state.
Class-Scope – Applies to a class rather than an individual object.
4. Relationships in Class Diagrams
Association: A relationship among instances of object classes.
Association Role: The name given to the connection between classes.
Association Name vs. Association Role:
Either can be used, but at least one must be present.
Roles appear at both ends of the association.
Names go between classes, sometimes with an arrow to indicate direction.
Multiplicity: Defines how many instances of one class can be associated with another class.
Example:
"A customer can place multiple orders" → 1:* multiplicity.
Structural Links:
A solid line between two classes represents an association.
5. Encapsulation
Definition: Hiding the internal implementation of an object from external access.
Purpose: Protects data and ensures controlled access.
Example:
Private attributes and public methods in a class.