Professional Documents
Culture Documents
KM e
KM e
KM e
First View
Agree on OOD
Class Diagram
● Associate the actors and use cases -- there shouldn't be any actor
or use case floating without any connection
● Be careful on specifying relationships
6
Classes
A class:
○ A unit of abstraction in an object oriented (OO) program
○ Template or blueprint of objects
10
A View of the procedural and object-oriented
paradigms
Instance Variables
Variables defined inside a class corresponding to data present in each instance
○ Also called fields or member variables
○ Attributes
■ Simple data
■ E.g. name, dateOfBirth
○ Associations
■ Relationships to other important classes
■ E.g. supervisor, coursesTaken
14
Organizing Classes into Inheritance Hierarchies
●Super classes
○ Contain features common to a set of subclasses
●Inheritance hierarchies
○ Show the relationships among super classes and subclasses
○ A triangle shows a generalization
17
●Inheritance
○ Subclasses implicitly have the features defined in its superclasses
Polymorphism
21
22
Dynamic binding
●Occurs when decision about which method to run can only be made at run
time
○ Needed when:
■ A variable is declared to have a superclass as its type, and
■ There is more than one possible polymorphic method that could be run
among the type of the variable and its subclasses
25
• In the design of a system, a number of classes
are identified and grouped together that
helps to determine the static relations
between them.
Essentials of UML Class Diagrams
●The main symbols shown on class diagrams are:
○ Classes
● represent the types of data themselves
○ Attributes
● are simple data found in classes and their instances
○ Operations
● represent the functions performed by the classes and their instances
○ Associations
● represent linkages between instances of classes
○ Generalizations
● group classes into inheritance hierarchies
Associations and Multiplicity
An association is used to show how two classes are related to each
other. Symbols indicating multiplicity are shown at each end of the
association
Labelling associations
○ Each association can be labelled, to make explicit the nature of
the association
Analyzing and validating associations
○ Onetoone
■ For each company, there is exactly one board of directors
■ A board is the board of only one company
■ A company must always have a board
■ A board must always be of some company
Analyzing and validating associations
●Avoid unnecessary onetoone associations
Association classes
Grade???
Association classes
○ Sometimes, an attribute that concerns two associated classes
cannot be placed in either of the classes
○ The following are equivalent
Generalization
●Specializing a superclass into two or more subclasses
○ A generalization set is a labeled group of generalizations with a
common superclass
○ The label (sometimes called the discriminator) describes the
criteria used in the specialization
Relationships
Composition
A composition is a strong kind of aggregation
■ if the aggregate is destroyed, then the parts are destroyed as
well
Composition Example
Abstract class
• When the concrete implementation of methods
are left for the subclasses.
• Can contain both abstract and non-abstract methods
Abstract class
Suggested sequence of activities
○ Identify a first set of candidate classes
○ Add associations and attributes
○ Find generalizations
○ List the main responsibilities of each class
○ Decide on specific operations
○ Iterate over the entire process until the model is satisfactory
■ Add or delete classes, associations, attributes, generalizations,
responsibilities or operations
■ Identify interfaces
Object Diagrams
○ A link is an instance of an association
■ In the same way that we say an object is an instance of a class
A class diagram can generate an infinite number of object diagrams
Interaction Diagrams
○ An interaction diagram is often built from a use case and a class diagram.
■ The objective is to show how a set of objects accomplish the required interactions with
an actor.
○ Interaction diagrams show how a set of actors and objects communicate with each
other to perform:
● Sequence
● Timing
● Communication
Sequence diagrams
Sequence diagrams –
same example, more details
Sequence diagrams –
an example with object deletion
Exercise:
A caller calls to his/her friend (Recipient): Complete the diagram by
choosing the appropriate messages.
States
○ It will remain in this state until an event occurs that causes it to change state.
○ Special states:
21
○ tic-tac-toe game
22
State diagrams – an example with conditional
transitions
25
○ Activities
○ Actions
26
State diagram – an example with activity
29
30
Nested substates
33
34
Activity Diagrams
37
38
Representing concurrency
41
Representing concurrency
○ If one incoming transition occurs, a wait condition occurs at the join until the other
transitions occur.
42
Activity Diagram Notation …..
45
46
49
● Consider a bulb with a push down switch. The bulb initially remains off.
When the switch is pushed down, the bulb is on. Again when the switch is
pushed up, the bulb turns off. The lifecycle of the bulb continues in this way
until it gets damaged.
Draw State Diagram – Give meaningful names for the states and the
events. Show the actions in each of the states.
Usecase
—
While a usecase itself might drill into a lot of detail about every possibility,
a use-case diagram can help provide a higher-level view of the
system.
—
Use case diagrams can be a good communication tool for stake
holders.
Inclusions
• Allow one to express commonality between several different use cases.
12