Professional Documents
Culture Documents
Class Diagram
Chapter 4, 5 & 8
The Unified Modeling Language User Guide
SECOND EDITION
By Grady Booch, James Rumbaugh, Ivar Jacobson
Operations
Name Arguments visibility Return datatype Remarks
getStudentID Public Integer
setStudentName Name (Data Type: string) Public
getStudentAddress Public String
getCGPA Public Real
setNotice Note (Data Type: String) Public
Class Design – Case Study 1: Solution
Student
- studentID: integer {assigned by system}
- studentName: String {Maximum 30 characters}
- studentAddress: String
- /CGPA: Real
- Notice: String
+ getStudentID ( ): integer
+ setStudentName (Name : String)
+ getStudentAddress ( ): String
+ getCGPA ( ): Real
+ setNotice (Note: String)
Class Design – Case Study 2: Practice
Name of the class: Employee
Type of the Class: User
Attributes
Name Data type Visibility Remarks
EmpID Integer Private
EmpName String Private
EmpSalary Integer Private Derived from Grade
EmpDOB Date Private
Note String Private Static
Operations
Name Arguments visibility Return datatype Remarks
getID Public Integer
setName EmpName (Data Type: String) Public
setID EmpID (Data Type: Integer) Public
setNote Note (Data Type: String) Public Static
Relationship - Association
• Association name: The purpose of the association can be
expressed in a name, a verb or verb phrase that describes how
objects of one type (class) relate to objects of another type
(class).
Relationship - Association
• Association multiplicity: Multiplicity is the UML term for the rule that defines the
number of participating objects.
• Most common is a range defining the minimum number of objects allowed and the
maximum number of objects allowed in the format Minimum . . Maximum
• Association roles: Association multiplicity:
Relationship - Association
• Association constraints:
• Association Class:
Relationship - Association
• Reflexive association
• Qualified association
Relationship – Association
Aggregation & Composition
Aggregation
• Aggregation is a special type of association used to indicate that the participating
objects are not just independent objects that know about each other.
• Instead, they are assembled or configured together to create a new, more complex
object.
• Whole-part relationship
Composition
• Composition is used for aggregations where the life span of the
part depends on the life span of the aggregate.
Example
Problem statement: “Our Company maintains a group of race cars. Our cars use some of our new 8-cylinder engines
and new transmissions. Once the engines are assembled, the pistons, carburetor, and plugs cannot be swapped
between engines due to changes caused by the high temperatures.
“We want to keep records of the performance achieved by each engine in each car and each transmission in
combination with each engine. Our drivers evaluate each car to give us their assessment of the handling. We need a
system to track the configurations and the drivers’ assessments.”
Generalization
• Generalization and Inheritance are used synonymously
• A generalization is not an association
• Generalization and Specialization
• Generalization is bottom-up and Specialization is top-down
Example
• “Our system is designed to inventory and ship uniquely identified products. These products may be purchased directly from vendors and resold
as is, or we can package vendor products together to make our own custom product. Customers place orders for one or more items, but we
acknowledge interested customers in the system whether they have purchased yet or not. Each item corresponds to a product. We identify each
product using a unique serial number. The Customer may inquire on the status of his Orders using the order number.”
• “Shipments of products from vendors are received and placed into inventory. Each product is assigned to a location so that we can easily find it
later when filling orders. Each location has a unique location identifier. Customer orders are shipped as the products become available, so there
may be more than one shipment to satisfy a single customer order. But a single shipment may contain products from multiple orders. Any items
that have not been shipped are placed on a backorder with a reference to the original order.”
Case Study: Solution
Case 1:
• One Student may attend any number of courses * attend *
Student Course
• One course may have any number of students
• Instructors teach courses 0 .. * 0 .. *
teach
has
• For every course there is at least one instructor
• Every instructor may teach zero or more courses 1 .. *
1 .. *
• A school has zero or more students 1
• Each student may be a registered member of one School Instructor
or more school
1 .. 1 1 .. *
• A school has one or more departments
has
chair
• Each department belongs to exactly one school
• Every instructor is assigned to one or more 1 .. *
departments Department
• Each department has one or more instructors
• For every department there is exactly one 1 .. *
instructor acting as the department chair assigned to
Case Study: Solution
Case 2:
• A building is owned by one person
• A person may own more than one building
• Each building is either a house or an apartment
• An apartment contains two or more Rental Units
• A rental unit only belongs to one and only one apartment block
1 owns *
Person Building
Rental Unit
2 .. *
Apartment House
belongs to
1 .. 1
Case Study: Solution
Case 3: Affiliated with
Organization
A nonprofit organization depends on a
number of different types of persons for its Person
successful operation. Persons are affiliated * Section
works in
with organizations. Three types of persons
are of greatest interest: employees,
volunteers, and donors. Employees and Employee
supervise
volunteers work in various projects. One Project
project consists of many sections. A
Volunteer
volunteer works under the supervision of an
sponsors
employee. To become a recognized donor, a
works in
donor must have donated one or more
items, and an item may have no donors, or
one or more donors. Projects are sponsored Donor Sponsor
by sponsors. Sometimes a single project is *
* donate
sponsored by multiple sponsors. For 1 .. *
sponsorship, an agreement must be signed.
Item Agreement
Case Study: Practice
Case 4:
• A company has one or more divisions
• A division has one or more departments
• A company can have one or more persons working as employees
• A person works in a company as an employee
• A department has one or more persons assigned to it
• A person is assigned to one department
Case 5:
• There are members in the library. Members can borrow books. There can be
short-term borrowing or long-term borrowing. There are also journals in the
library. There is a special type of member- Member of Staff, who can borrow
the journals. The system must keep track when books and journals are
borrowed.
Case Study: Practice
Case 6:
• A member can be of three types- potential member, past member and club
member. Club members place orders. One order must include at least one
product. One product can be in many orders. There are two types of products -
club souvenirs and club facilities. Each member must sign an agreement. One
agreement can be made for more than one member. Club facilities are courts,
tables and halls. Courts are Badminton court and Tennis Court. Tables are for
Tennis and Pool. Club members can also book club facilities. For each booking,
date and duration of booking must be stored.