2
A CLASS is a template (specification, blueprint)
for a collection of objects that share a common
set of attributes and operations.
Health Club Member
Class
Objects
attributes
operations
Defining Class
UML Class Diagrams 3
What is a Class Diagram?
•A Class Diagram is a diagram describing the
structure of a system shows the system's
•classes
•Attributes
•operations (or methods),
•Relationships among the classes.
4
1 of 2
UML Class Diagram Notation
Class
Member
memberNumber
firstName
lastName
telephone
address
city
etc...
checkOutVideo
checkInVideo
buyItem
etc...
attributes
operations
{
{
Expanded view of a
Class into its three
sections:
Top: Class Name
Middle: attributes
Bottom: operations
5
2 of 2
Object Association
n n
Class
Generalization
Relationship
Object
Aggregation
Association
0..*
1..*
Object Composition
Association
0..*
1
Will always be “1”
UML Class Diagram Notation
UML Class Diagrams 6
Essential Elements of a
UML Class Diagram
Class
Attributes
Operations
Relationships
7
Association
Aggregation/Compostion
Dependencies
Generalization
Realization
8
Associations
An association between two classes describes connection
among them.
If the association is between two classes then it is called
binary association.
There can be association among more than two classes.
It is represented by a solid line.
Example: “An Employee works for a Company”
Employee Company
9
Class A Class B
role A
role B
Company Person
Employer
Employee
Example:
Associations
10
Aggregation & Composition
•Aggregation (shared aggregation):
• is a specialized form of ASSOCIATION in which a whole is
related to its part(s).
• is known as a “part of” or containment relationship and follows
the “has a” heuristic
• three ways to think about aggregations:
• whole-parts
• container-contents
• group-members
• Composition (composite aggregation):
• is a stronger version of AGGREGATION
• the “part(s)” may belong to only ONE whole
• the part(s) are usually expected to “live” and “die” with the whole
(“cascading delete”)
• Aggregation vs. Composition vs. Association???
11
Aggregation Composition
0..*
1..*
Faculty
CourseTeaching
1..*
1
SalesOrder
SalesOrderLineItem
(another: hand --> finger)(another: assembly --> part)
(team-teaching is
possible)
12
Generalization
• Deriving a class out of a parent class having
some inherited property(from the parent
class) and some new property of the derived
class.
• The term generalization is for the
inheritance in the bottom to the up direction
i.e. from derived class to the parent class.
• It is represented by a solid line with a large
arrow head pointing towards the parent
class.
• Example:
13
Vehicle
Car Truck
14
Dependency
• A dependency relationship is a weaker form
of relationship. A dependency states that a
change in specification of one class may
effect another class that uses first one but
not vice versa.
• It is represented by dashed lines.
Dependent class Reference class
15
Realization
• Realization is very similar to inheritance
,the only difference between them is a class
is derived from an interface instead of a
base class.
• An interface is an abstract class.
Interface class Derived class
16
UML Class Diagrams 17
UML Class Diagrams 18

Object and class relationships

  • 2.
    2 A CLASS isa template (specification, blueprint) for a collection of objects that share a common set of attributes and operations. Health Club Member Class Objects attributes operations Defining Class
  • 3.
    UML Class Diagrams3 What is a Class Diagram? •A Class Diagram is a diagram describing the structure of a system shows the system's •classes •Attributes •operations (or methods), •Relationships among the classes.
  • 4.
    4 1 of 2 UMLClass Diagram Notation Class Member memberNumber firstName lastName telephone address city etc... checkOutVideo checkInVideo buyItem etc... attributes operations { { Expanded view of a Class into its three sections: Top: Class Name Middle: attributes Bottom: operations
  • 5.
    5 2 of 2 ObjectAssociation n n Class Generalization Relationship Object Aggregation Association 0..* 1..* Object Composition Association 0..* 1 Will always be “1” UML Class Diagram Notation
  • 6.
    UML Class Diagrams6 Essential Elements of a UML Class Diagram Class Attributes Operations Relationships
  • 7.
  • 8.
    8 Associations An association betweentwo classes describes connection among them. If the association is between two classes then it is called binary association. There can be association among more than two classes. It is represented by a solid line. Example: “An Employee works for a Company” Employee Company
  • 9.
    9 Class A ClassB role A role B Company Person Employer Employee Example: Associations
  • 10.
    10 Aggregation & Composition •Aggregation(shared aggregation): • is a specialized form of ASSOCIATION in which a whole is related to its part(s). • is known as a “part of” or containment relationship and follows the “has a” heuristic • three ways to think about aggregations: • whole-parts • container-contents • group-members • Composition (composite aggregation): • is a stronger version of AGGREGATION • the “part(s)” may belong to only ONE whole • the part(s) are usually expected to “live” and “die” with the whole (“cascading delete”) • Aggregation vs. Composition vs. Association???
  • 11.
  • 12.
    12 Generalization • Deriving aclass out of a parent class having some inherited property(from the parent class) and some new property of the derived class. • The term generalization is for the inheritance in the bottom to the up direction i.e. from derived class to the parent class.
  • 13.
    • It isrepresented by a solid line with a large arrow head pointing towards the parent class. • Example: 13 Vehicle Car Truck
  • 14.
    14 Dependency • A dependencyrelationship is a weaker form of relationship. A dependency states that a change in specification of one class may effect another class that uses first one but not vice versa. • It is represented by dashed lines. Dependent class Reference class
  • 15.
    15 Realization • Realization isvery similar to inheritance ,the only difference between them is a class is derived from an interface instead of a base class. • An interface is an abstract class. Interface class Derived class
  • 16.
  • 17.
  • 18.