Professional Documents
Culture Documents
• Classes are abstractions that allow us to deal with whole collections of objects
that share some commonalties.
• Examples of classes in a Student Records Management System
Course College
Class Semester Instructor
Section
Student
Class Department
Grade Major
Class Syntax
• A box divided into compartments Student
• Name
• Attributes major: String
• Operations gpa: Real
• Responsibilities
• Used-defined compartments
standing: String
add(Class Section)
drop(Class Section)
-- The set of students
known to the registration
system
-- An exception occurs if
gpa falls below 2.0
Class Names
• The name should be a noun or noun phrase
• The name should be singular and description of each object in the
class
• The name should be meaningful from a problem-domain perspective
• “Student” is better than “Student Data” or “S-record” or any other
implementation driven name
• Avoid jargon in the names
• Try to make the name descriptive of the class’s common properties
Exercise – Class Identification
add(Class Section)
drop(Class Section)
Attributes
• Attributes represent characteristics or properties of objects
• They are place holders or slots that hold values
• The values they hold are other objects
• The name of an attribute communicates its meaning
• An attribute can be defined for individual objects or classes of objects
• If defined for a class, then every object in the class has that attribute (place
holder)
Attributes from an Analysis Perspective
joe: Student
Is basically the
name: String = “Joe Jones”
same as ...
Course <has
Prerequisite
Operation Syntax
[visibility] name [(parameter-list)] [:return-
type] [{property-strong}]
visibility: “+”, “#”, “-”
name: verb or verb phase, capitalize first letter of every word, except first
parameter-list: coma separated list of parameters
return-type: primitive type or user-defined type
property-string: isQuery, sequential, guarded, concurrent
Type of Relationships in Class Diagrams
Relation
Aggregation
Associations
• An association is a structural relationship that specifies that objects of
class may be connected to objects of another class
• Meaning from three perspectives
• Analysis: Links between objects
• Specification: Obligation to provide a connection between objects
• Implementation: Object pointers, references, linking structures, etc.
Associations
is registered for>
Student Semester
g>
ri n
tak
es>
du
ld
he
is
teaches> Class
Instructor
Section
is
<works for
in
st
an
ce
of
>
sponsors>
Department Course
Coming up: Association Names
Association Names
• Associations may be named
• The names should communicate the meaning of the links
• The names are typically verb phases
• The name should include an arrow indicating the direction in which the name
should be read
Navigation
• The navigation of associations can be
• uni-directional
• bi-directional
• unspecified
teaches> Class
Instructor
Section
is
<works for
in
st
an
ce
of
>
sponsors>
Department Course
Coming up: Navigation
Generalization
• Generalization is another kind of relationship in UML – see Meta
Model
• From an analysis perspective, it is a pure generalization/specialization
concept, i.e., the specialization is a subset of the generalization
Graduate
Person Student
Student
Generalization
• From a specification/implementation perspective,
generalization can represent sub-typing,
inheritance, type capability, and substitutability
(depends on the language)
Student
Person
major: String
name: String GPA: Real
address: String standing: String
g>
ri n
tak
es>
du
ld
he
0..8
1..*
is
teaches> Class
Instructor
1..3 0..6 Section
1..* is
<works for
in
st
an
ce
of
1 >
1 sponsors> 1..*
Department Course
Coming up: Multiplicity Constraints
Questions
Relation
Aggregation
Dependencies
• A dependency is a type of relationship
• It says that one modeling component “uses” another.
• If the later changes then, the former may have to change as well
Student
Prerequisite
add(Course)
drop(Course)
Coming up: Dependencies
Dependencies
• Meaning from three perspectives
• Analysis: physical or logical dependency between the connected classes
• Specification: a “uses” relationship at an interface level
• Implementation: a “uses” relationship at an implementation level.
Relation
Aggregation
Aggregation
• Aggregation: is a special kind of association that means “part of”
• Aggregations should focus on single type of composition (physical,
organization, etc.)
Crust 1 1
1
1 1 *
Sauce Serving Pizza Order
1..3 1 1
Cheese Serving
0..9 1 4..*
Topping Serving
Slice
Composition (very similar to aggregation)
Room Building
Lets look at BookstoreExample4.jpg
• Does John McCain (who has 7 houses) have a problem using this
system?
• If Barack Obama decides to create a Federal sales tax, how would we
change the system?
• Why is there a display method in Item, Book, MusicCD and Software?
• An ItemOrder is part of how many Orders?
• Can you explain how a search works using this diagram?
Class Exercise
• How can you manage change control on all the class diagrams for
project?
• What do you do with class diagrams after a system has been built
and delivered?
Bonus Slide!