Вы находитесь на странице: 1из 184

Modelling with Classes

Hari Prasad Pokhrel(hpokhrel24@gmail.com)


What constitutes a good model?
…A model should
† use a standard notation
† be understandable by clients and users
† lead software engineers to have insights about the system
† provide abstraction

…Models are used:


† to help create designs
† to permit analysis and review of those designs.
† as the core documentation describing the
. system

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Static: Class Diagram (Rumbaugh/Booch)
… Utilizedfor Static Structure of Conceptual Model
… Class Diagram Describes
† Types of Objects in Application
† Static Relationships Among Objects
† Temporal Information Not Supported
… Class Diagrams Contain
† Classes: Objects, Attributes, and Operations
† Packages: Groupings of Classes
† Subsystems: Grouping of Classes/Packages
… Main Concepts:
Class, Association, Generalization, Dependenc
Realization, Interface
… Granularity Level of -Cases
Use is Variable
Hari Prasad Pokhrel (hpokhrel24@gmail.com)
Essentials of UML Class Diagrams
…The main symbols shown on class diagrams are:
† Classes
„ represent the types of data themselves
† Associations
„ represent linkages between instances of classes
† Attributes
„ are simple data found in classes and their instances
† Operations
„ represent the functions performed by the classes and their instance
† Generalizations
„ group classes into inheritance hierarchies

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Classes
y A class is simply represented as a box with the name of the class inside
y The diagram may also show the attributes and operations
y The complete signature of an operation is:
operationName(parameterName: parameterType …): returnType

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Hari Prasad Pokhrel (hpokhrel24@gmail.com)
The Class Diagram Notation
y Identify classes, attributes of each class, and operation
each class
y Classes, their attributes and methods are specified bas
on the objects needed to realized use case and interfac
to external entities
Detailed
Attributes,
Data types,
And operations
Are defined/
refined
Hari Prasad Pokhrel During design
(hpokhrel24@gmail.com)
Hari Prasad Pokhrel (hpokhrel24@gmail.com)
Hari Prasad Pokhrel (hpokhrel24@gmail.com)
Associations and Multiplicity
y Anassociation
is used to show how two classes are related to each other
y Symbols indicating
multiplicity
are shown at each end of the association

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Object Diagrams
… Object (Instant) Diagrams give a representation of a class diagram using actual m.
objects
For in the syste
example if this is our class diagram:

… Which of the following object diagrams are valid?

Homer
Homer
Homer
Homer Walmart
Walmart
Walmart
Walmart
Lisa
Lisa
Lisa
Lisa Sears
Sears
Sears
Sears
Bart
Bart
Bart
Bart

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Labelling associations
y Each association can be labelled, to make explicit the nature of the
association

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


„ A Student can take many Courses and many Students
can be enrolled in one Course.

Student Course
* takes *

Alice: Student 254: Course

Jill: Student 253: Course


Hari Prasad Pokhrel (hpokhrel24@gmail.com)
Analyzing and validating associations
y Many-to-one
y A company has many employees,
y An employee can only work for one company.
y This company will not store data about the moonlighting activities o
employees!
y A company can have zero employees
y E.g. a ‘shell’ company
y It is not possible to be an employee unless you work for a company

Employee * worksFor 1 Company

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Analyzing and validating associations
y Many-to-many
y A secretary can work for many managers
y A manager can have many secretaries
y Secretaries can work in pools
y Managers can have a group of secretaries
y Some managers might have zero secretaries.
y Is it possible for a secretary to have, perhaps temporarily, zero manag

Secretary * 1..** Manager


supervisor

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Analyzing and validating associations
y One-to-one
y For each company, there is exactly one board of directors
y A board is the board of only one company
y A company must always have a board
y A board must always be of some company

1 1
Company BoardOfDirectors

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Multiplicity
y Multiplicity can be expressed as,
y Exactly one- 1
y Zero or one- 0..1
y Many- 0..* or *
y One or more- 1..*
y Exact Number - e.g. 3..4 or 6
y Or a complex relationship
– e.g. 0..1, 3..4,6..* would mean
any number of objects other than 2 or 5

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Analyzing and validating associations
y Avoid unnecessary-to-one
one associations
y Avoid this do this

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Question
:
y Label the multiplicities for the following examples
__ rented __
Customer Video
__ currentlyRenting __

Woman __ __ Child
givesBirthToo

Brother __ Sister
__ has

__ currentlyOnIceFor __ Hockey Team


League
__ AssignedTo __
Player
Hari Prasad Pokhrel (hpokhrel24@gmail.com)
Question
…In words, what do these diagrams mean?

Country City
0..1 hasCapital 1

Person Colour
* favourite 0..1

one and only one city as its capital


…A Country has _________________________
…A City ____________________

…A Colour________________________
…A Person _________________________

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Another Question:
y Correctly label this diagrams multiplicity:

Car ? listeningTo ? Radio Station


? couldTuneInto ?

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


A more complex example
y A booking is always for exactly one passenger
y no booking with zero passengers
y a booking could
never
involve more than one passenger.
y A Passenger can have any number of Bookings
y a passenger could have no bookings at all
y a passenger could have more than one booking

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Question
y Create two or three classes linked by associations to
represent the following situations:
• A landlord renting apartments to tenant
• An author writing books distributed by publishers
y Label the multiplicities (justify why you picked them)
y Give each class you choose at least 1 attribute

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Your Answer

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Reflexive associations/self association.
y It is possible for an association to connect a class to itself
y An association that connects a class to itself is called a self
association.

successor
isMutuallyExclusiveWith
Course
prerequisite
At TU, you can’t take
At TU, you must have Calc 1301b and
CS2210 and CS2211 to Calc1501b
take CS2212

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Association - Self

„ A Company has Employees.


„ A single manager is responsible for up to 10 workers.

1
Employee
manager
Responsible worker
for 0..10
Association - Multiplicity

„ A cricket team has 11 players. One of them is the


captain.
„ A player can play only for one Team.
„ The captain leads the team members.

Captain
Team
Mem Player 1 0..1Team
ber 10
11 member of 1
1 Captain

Leads
Association classes
y Sometimes, an attribute that concerns two associated classes cannot b
placed in either of the classes
y The following are equivalent

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Question
y Add association classes to the following many to many
associations and come up with at least one attribute for the
association class:

Guest * stay in * HotelRoom

Spectator * Show
* attended

Player * * SportsGame
participated in

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Hari Prasad Pokhrel (hpokhrel24@gmail.com)
Class Relationships
ƒ Association
ƒAggregation
ƒComposition
ƒ Generalization
ƒ Realization
ƒ Dependency

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Generalization (Inheritance)
y Child class is a special case of the parent class

SuperClass

SubClass1 SubClass2

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Generalization/Specialization Relation

y Specializing a superclass into two or more subclasses


y Thediscriminator
is a label that describes the criteria used in the
specialization

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Generalization/Specialization Relation

„ Generalizationis shown as a solid-line


arrow from the child (the more specific
element)to the parent (the more general
element)this type of relationship is also
calledinheritance.
„ Shouldbe usedto define classhierarchiesbased
on abstraction

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Generalization/Specialization Relation

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Avoiding unnecessary generalizations

Inappropriate hierarchy of classes, which should be instances


Ask yourself: Does this class require any operations that will be
done differently than the other classes? If answer is no, don’t make
it a class!

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Avoiding unnecessary generalizations
(cont)

Improved class diagram, with its corresponding instance


diagram
Hari Prasad Pokhrel (hpokhrel24@gmail.com)
Handling multiple discriminators
y Creating higher
-level generalization
y Say we had a Prey class, we would need TWO associations instead of
just one.

Prey

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Handling multiple discriminators
† Using multiple inheritance

† Using the Player


-Role pattern

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Avoiding having instances change class
y An instance should never need to change class
y This is a poor model:

y A bit better solution, but then we lose the polymorphism advantage for
any operations that differ between FullTimeStudent and
PartTimeStudent:

Student
attendanceStatus
Hari Prasad Pokhrel (hpokhrel24@gmail.com)
Multiple inheritance

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Generalization (Inheritance) e.g.

Circle

GraphicCircle

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Inheritance - Implementation

public class Circle {

public class GraphicCircle extends Circle {

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Abstract Class

Shape

Circle Rectangle

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Abstract Methods (Operations)

Shape
draw()

Circle Rectangle

draw() draw()

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Abstract class and method
Implementation

public abstract class Shape {


public abstractdraw(); //declare
without implementation
………
}

public class Circle {


public draw(){
…….
}
…..
}
Hari Prasad Pokhrel (hpokhrel24@gmail.com)
Class Relationships
ƒ Association
ƒ Generalization
ƒ Realization
ƒ Dependency

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Realization- Interface
y Interface is a set of operation the class carries out

Keyboard Keyboard

brandName <<interface>> brandName


numOfKeys TypeWriter numOfKeys
OR
ctl() ctl()
TypeWriter
pageDown() keyStroke() pageDown()

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Realization- Implementation

public interface TypeWriter{


void keyStroke()

public class KeyBoard implements TypeWriter


{
public void keyStroke(){
………

}
}

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Class Relationships
ƒ Association
ƒ Generalization
ƒ Realization
ƒ Dependency

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Dependency : A Special Case of
Association
y Change in specification of one class can change the othe
This can happen when one class is using another class.

Circle
Point
Move(p:Point)

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


import java.awt.Graphics;
class HelloWorld extends java.applet.Applet {
public void paint (Graphics g) {
g.drawString("Hello, World!", 10, 10);
}
}

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Dependency cont
y Dependency relationship can be used to show relationsh
between classes and objects.

circleA:Circle

Circle

circleB:Circle

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Dependency
Dependency

Client
CommandManager

TimerEvent RequestHandler ResponseHandler

CommandManager (Client class) depends on services


provided by the other three server classes

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


This figure shows a dependency from
CourseSchedule
to
Course,becauseCourseis used in both the
addand
removeoperations ofCourseSchedule.

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Class Diagram - Example
… Draw a class diagram for a information modeling syst
for a school.
† School has one or more Departments.
† Department offers one or more Subjects.
† A particular subject will be offered by only one department.
† Department has instructors and instructors can work for one
or more departments.
† Student can enrol in upto 5 subjects in a School.
† Instructors can teach upto 3 subjects.
† The same subject can be taught by different instructors.
† Students can be enrolled in more than one school.

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Class Diagram - Example
y School
has one or more
Departments
.

School Department
1 has 1..*

„ Department offers one or more Subjects.


„ A particular subject will be offered by only one
department.

Department Subject
1 offers 1..*
Hari Prasad Pokhrel (hpokhrel24@gmail.com)
Class Diagram - Example
y Department has Instructors and instructors can work
one or more departments.

Instructor Department
1..* assigned to 1..*

„ Student can enrol in upto 5 Subjects.

Student Subject
* takes 0..5
Hari Prasad Pokhrel (hpokhrel24@gmail.com)
Class Diagram - Example
y Instructors can teach up to 3 subjects.
y The same subject can be taught by different instructors.

1..*
Instructor Subjects
teaches 1..3

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Class Diagram - Example
y Students can be enrolled in more than one school.

*
Student School
member 1..*

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Class Diagram Example
has

School Department
1 1..* 1..*
1…* 1
offeres
assignedTo
member

* 1..* 1..*
attends teaches Instructor
Student Subject
* 1..5 1..31..*
Hari Prasad Pokhrel (hpokhrel24@gmail.com)
Object Diagram
y Object Diagram shows the relationship
between objects.

y Unlike classes objects have a state.

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Object Diagrams
y A linkis an instance of an association
y In the same way that we say an object is an instance of a class

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Object Diagram
Track Instance Behavior
y Class
Diagram

y Instance
Diagram

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Object Diagram
y Captures Instances and Links

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Hari Prasad Pokhrel (hpokhrel24@gmail.com)
Hari Prasad Pokhrel (hpokhrel24@gmail.com)
Hari Prasad Pokhrel (hpokhrel24@gmail.com)
Question:
y Draw a class diagram corresponding to the following
situation:
• A media player
Most
( software media players support an array of media formats
like Quicktime for Macs or Windows Media Player for)that
Windows
can handle
sound, images and sequences of images. Each type of medium-in” requires a “pl
(plug-in is a set of software components that adds specific capabilities to a larg
software application)
, although some plug
-ins can handle more than one type of
medium.
• An organization has three categories of employee: professional staff, technic
staff and support staff. The organization also has departments and divisions.
employee belongs to either a department or a division. Assume that people w
never need to change from one category to another.

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Your Answer:

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Question:
y Draw a class diagram that could generate the object diagra
shown below:
isMemberOf
United Nations: Canada:
isMemberOf
isPartOf

France:
Ontario:
isMemberOf isPartOf
isMemberOf
isMemberOf borders
borders

NATO: Quebec: borders

isMemberOf borders

Mexico:
isPartOf New York State:
borders

United States:

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Your answer:

PoliticalEntity
name
borders

*
* Territory InterGovernmentalOrganization
* isMemberOf *

1 isPartOf *
Country StateOrProvince

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Associations versus generalizations in
object diagrams
† Associations describe the relationships that will exist betwee
instances
at run time.
„ When you show an instance diagram generated from a class diagram
there will be an instance
both
ofclasses joined by an association

† Generalizations describe relationships classes


between
in class
diagrams.
„ They do not appear in instance diagrams at all.
„ An instance of any class should also be considered to be an instance
each of that class’s superclasses

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


More Advanced Features: Aggregation

y Aggregations are special associations that represent


-whole’‘part
relationships.
y The ‘whole’ side is often called
assembly
the or theaggregate
y This symbol is a shorthand notation association
isPartOf
named

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


When to use an aggregation
…As a general rule, you can mark an association as an aggrega
following are true:
† You can state that
„ the parts ‘are part of’ the aggregate
„ or the aggregate ‘is composed of’ the parts
† When something owns or controls the aggregate, then they also
or control the parts

NOTE: Might be able to say a person is part of a club BUT


the owner of the club does NOT own the members

Club 1 * Member

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Composition: A Special case of
Aggregation
y A composition
is a strong kind of aggregation
y Composition is shown as a solid filled diamond, with the diamond attached to the class th
is the composite. Composition is a form of aggregation that requires coincident lifetime o
the part with the whole and singular ownership; i.e. the part is owned by only one whole
and is deleted when the whole is deleted
y if the aggregate is destroyed, then the parts are destroyed as well

y Two alternatives for addresses

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Composition example

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Aggregation vs Composition

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Propagation
† A mechanism where an operation in an aggregate is implemented by having
the aggregate perform that operation on its parts
† At the same time, properties of the parts are often propagated back to the
aggregate
† Propagation is to aggregation as inheritance is to generalization.
„ The major difference is:
„ inheritance is an implicit mechanism
„ propagation has to be programmed when required
„ Eg. Deleting a polygon means deleting the line segments

† Marking a part
-whole association as an aggregation using the diamond symbol
is optional. Leaving it as an ordinary association is not an error, whereas
marking a non-aggregation with a diamond is an error, therefore,
when in
doubt, leave it out!

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Question
… For each of the following associations, indicate whether
should be
anordinary association
astandard aggregation
acomposition

a) A telephone and its handset


b) A school and its teachers
c) A book and its chapters

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Interfaces
y Aninterface
describes
aportionofthevisible
behaviour
of asetof objects
.
y An interface
is similar to a class, except it lacks instance variables and
implemented methods
y Although Employee and ATM share common operations they have differe
superclasses. This means they cannot be put in the same inheritance hie
therefore the interface called Cashier is used
y A key advantage of using interfaces is that they can reducecoupling
what is called
between classes.
y Inheritance indicatesisarelationship,
an interfaces indicate
can-be
a -seen
-as
relationship

«interface»
Person Cashier Machine Person Machine

withdraw
Cashier Cashier
deposit

Employee ATM Employee ATM

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Interfaces
… Interface
and Stereotypes
– Operation Signatures (Abstract Class)
… Stereotype
– Extend UML with New Modeling Items Created fro
Existing Kinds (Classes)

Balloons
for Interfaces

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


The Process of Developing Class
Diagrams
y You cancreateUML modelsat differentstagesand with
differentpurposes
andlevelsof details
y Exploratory domain model:
y Developed
in domainanalysis
to learnaboutthedomain
y Systemdomain model:
y Modelsaspects
of thedomainrepresented
bythesystem
y Systemmodel:
y Includesalso classesusedto build the user interfaceand system
architecture

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


System domain model vs System
model
y The system
domainmodelomits manyclasses
that are neededto build a
completesystem
y Cancontainlessthanhalftheclasses
of thesystem
.
y Should be developed to be used independently of particular sets of
y user interface classes
y architectural classes
y Thecomplete
system
model
includes
y Thesystem
domainmodel
y Userinterface
classes
y Architectural
classes
suchasthedatabase,
files,servers,
clients
y Utility classes

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Suggestedsequenceof activities
† Identifyafirstsetof candidate
classes
† Addassociationsandattributes
† Findgeneralizations
† Listthemainresponsibilities of eachclass
† Decideonspecificoperations
† Iterate overtheentireprocessuntilthemodelissatisfactory
„ Add or delete classes, associations, attributes, generalizations,
responsibilities or operations
„ Identify interfaces
„ Apply design patterns
… Don’tbetoodisorganized
. Don’tbetoorigideither
.

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Identifyingclasses
y Whendeveloping
adomainmodelyoutendto discover
classes
y When you work on the user interfaceor the system
architecture,
youtendto inventclasses
y Needed
to solveaparticulardesignproblem
y (Inventing
mayalsooccurwhencreatingadomainmodel)
y Reuseshouldalwaysbeaconcern
y Frameworks
y System extensions
y Similarsystems

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


A simple technique for discovering
domain classes
y Lookatasourcematerialsuchasadescription
of requirements
y Extractthenouns
andnounphrases
y Eliminate
nounsthat:
y areredundant
y represent
instances
y arevague
or highlygeneral
y not neededin the application
. For examplein a domainmodel,you
wouldeliminateclasses thatrepresent command or menusin theUI. As
aruleof thumb,a classisonlyneeded in adomainmodelif youhaveto
storeor manipulateinstancesof it in orderto implementarequirement
y Payattentionto classes
in a domainmodelthatrepresenttypesofusers or
otheractors

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Identifyingassociationsand attributes
y Startwithclasses
youthinkaremostcentral andimportant
y Decideon the clearandobviousdatait mustcontainandits
relationships
to otherclasses
.
y Workoutwards towardstheclasses
thatarelessimportant.
y Avoidaddingmanyassociationsandattributesto aclass
y A system
issimplerif it manipulates
lessinformation

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Tips about identifying and specifying
valid associations
† Anassociation shouldexistif aclass
„ possesses
„ controls
„ isconnectedto
„ isrelated
to
„ isapartof
„ hasasparts
„ isamember of, or
„ hasasmembers
someotherclassin yourmodel
† Specifythemultiplicityatbothends
† Labelit clearly
.

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Actions versus associations
y A commonmistake
isto represent
actions
asif theywereassociations

Better: Theborrow operation creates a


Loan object and the return operation set
Bad, due to the use of
the returnedDate attribute
associations that are actions

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Identifyingattributes
y Lookfor information
thatmustbemaintained
abouteachclass
y Severalnounsrejectedasclasses,
maynowbecome
attributes
y Anattributeshouldgenerally
containasimplevalue
y E.g. string,number

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Tips about identifying and specifying
valid attributes
y It isnotgoodto havemanyduplicate
attributes
y If a subsetof a class’sattributesform a coherentgroup,then
createadistinctclasscontaining
theseattributes
Person Person Address
1*
Person *
name name street
addresses
street1 municipality
name municipality1 provOrState
addresses provOrState1 country
country1 postalcode
Bad due to a plural postalCode1 type
attribute street2
municipality2 Good solution. The
provOrState2 type indicates whether
country2
postalCode2
it is a home address,
business address etc.
Bad due to too many
attributes, and inability
to add more addresses
Hari Prasad Pokhrel (hpokhrel24@gmail.com)
An example (attributes and
associations)

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Identifying generalizations and
interfaces
† Therearetwowaysto identifygeneralizations :
„ bottom-up
„ Grouptogethersimilarclassescreatinganewsuperclass
„ top-down
„ Lookfor moregeneralclassesfirst,specialize
themif needed
† Createaninterface , insteadof asuperclass if
„ Theclasses areverydissimilarexceptfor havinga few operations
in
common
„ Oneor moreof the classesalreadyhavetheirownsuperclasses
„ Differentimplementations
of thesameclassmightbeavailable

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Anexample(generalization)

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Case Study
… Implement the game
Boogle
of
… http://www.hasbro.com/scrabble/en_US/boggleGame.cfm
… Some Specs:
• There is an admin mode, tournament mode, fun play mode
† To get into admin mode type:
javaUWOBoggle
-admin
† To get into tournament mode or fun play mode
javatype:
UWOBoggle
„ Then select Tournament or Fun Play
• In Admin Mode Must Be able to
† Manage players:
• Add, delete and modify players. Players have a first name, userid
lastand
name,
password.
• Sort players by first and last name Player C
• Reset password Player A
Player B
† Manage puzzles (puzzles are made up of 16 puzzleid letters )and Winner
• Add, delete, bulkload, solve (using a stored dictionary of valid words) and
puzzleid
list by Player B Player B
† Manage tournaments -8 (2
players per tournament, tournament has a unique tournament id and a name. A tournament
-
3 battles of 2 per round, winning player moves to the next round)
• Add tournaments
• Add players to a tournament, add puzzles (all players play the same puzzle on each s, higher
round scorer
but in pair
for
each pair moves to the next round, in odd numbers, the highest scorer get a buy toothea tournament
next round) t
(must keep track of the score for each player for each round and the winner of each pairing)
• Delete tournaments
• List tournaments by tournament id or by tournament name
• Print tournaments

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


More Specs
•In Tournament or Fun Play Mode a user must be able to:
•Log on (gets 3 attempts and then kicked out)
•Play puzzles as follows
•Start the puzzle
•Given 3 minutes to find words
•Given a score at the end
•If the puzzle is not a tournament puzzle, the player can see the solution for the puzzle.
•In just Tournament Mode
•Player sees a list of tournaments that he/she is participating in
•Picks an ongoing tournament
•Plays the puzzles
•Sees if he/she moves to the next round

•In just Fun Mode


•Pick a puzzle from the list of puzzles
•Play the puzzle
•View the top 3 scores for that puzzle
•See the top 3 players (who have the highest scores for any games)

Working in pairs, determine the nouns and noun phrases that


might, in the end, become potential classes. Add the attributes an
associations. While making your list, choose good names for eac
of the potential classes
REMEMBER you only need classes in the domain model for
things that need to have data stored about them!
Hari Prasad Pokhrel (hpokhrel24@gmail.com)
Your Answer

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Laura’s Use Case
Diagram for the
ProjectÆ

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Laura’s Class
Diagram for the
ProjectÆ

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


One group’s class diagram for the project. This one has
problems…Can you see them?

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Hari Prasad Pokhrel (hpokhrel24@gmail.com)
Hari Prasad Pokhrel (hpokhrel24@gmail.com)
Hari Prasad Pokhrel (hpokhrel24@gmail.com)
Hari Prasad Pokhrel (hpokhrel24@gmail.com)
Question
y Identify any generalizations or interfaces. This may lead yo
add or delete classes, associations and attributes. Modify yo
class diagrams accordingly.

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Allocating responsibilities to
classes
y A responsibility
issomething
thatthesystemisrequiredto do.
y Eachfunctional
requirement mustbeattributedto oneof theclasses
y All theresponsibilities
of agivenclassshouldbeclearly
related
.
y If aclasshastoomanyresponsibilities,
considersplittingit intodistinctclasses
y If aclasshasnoresponsibilities
attached
to it, thenit isprobablyuseless
y Whenaresponsibilitycannotbeattributedto anyof theexistingclasses,then
anewclass
shouldbecreated

y Todetermine
responsibilities
y Performusecaseanalysis
y Lookfor verbsandnounsdescribing
actions
in thesystemdescription

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Categoriesof responsibilities
† Settingandgettingthevaluesof attributes
† Creatingandinitializingnewinstances
† Loadingto andsavingfrompersistent storage
† Destroyinginstances
† Addinganddeletinglinksof associations
† Copying, converting, transforming, transmitting or outputting
† Computing numerical results
† Navigatingandsearching
† Otherspecializedwork

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


An example (responsibilities)
• Creating a new regular flight

• Searching for a flight

• Modifying attributes of a
flight

• Creating a specific flight

• Booking a passenger

• Canceling a booking

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Prototyping a class diagram on paper
y As you identify classes, you write their names on small cards
y As you identify attributes and responsibilities, you list them o
the cards
y If you cannot fit all the responsibilities on one card:
y this suggests you should split the class into two related classes.
y Movethecardsaroundonawhiteboard
to arrangetheminto a
classdiagram
.
y Draw lines amongthe cardsto representassociations
and
generalizations
.

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Identifyingoperations
y Operations
areneededto realizethe responsibilities
of each
class
y Theremaybeseveral
operations
perresponsibility
y The main operationsthat implementa responsibilityare
normallydeclared
public
y Othermethodsthat collaborate
to performthe responsibility
mustbeasprivateaspossible

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Anexample(classcollaboration)

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


SpecificFlight * 0..1 Airplane

Classcollaboration‘a’
… Making a bi-directional
linkbetween
twoexisting
objects
;
… e.g. addinga link betweenan instanceof SpecificFlight
andaninstance
of Airplane .

… 1. (public)Theinstance
of SpecificFlight
„ makesa one-directional link to the instanceof Airplane
„ then calls operation 2.
… 2. (non-public)Theinstance
of Airplane
„ makes a one-directional link back to the instance of
SpecificFlight

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


SpecificFlight 1 0..1
0..1 FlightLog

Classcollaboration‘b’ + createFlightLog [b1] FlightLog [b2]

… Creating
anobject
andlinkingit toanexisting
object
… e.g. creating a FlightLog , and linking it to a
SpecificFlight .

… 1. (public)Theinstance
of SpecificFlight
„ calls the constructor of FlightLog (operation 2)
„ then makesa one-directional link to the new instance of
FlightLog .
… 2. (non-public)ClassFlightLog ’s constructor
„ makes a one-directional link back to the instance of
SpecificFlight .

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


PassengerRole Booking SpecificFlight
+ makeBooking [c1] 1 * * 1
Booking [c2] addLinkToBooking [c3]
addLinkToBooking [c4]

Classcollaboration‘c’
… Creating
anassociation
class,
giventwoexisting
objects
… e.g. creating an instanceof Booking, which will link a
SpecificFlight to aPassengerRole.
… 1. (public)Theinstanceof PassengerRole
„ callstheconstructor
of Booking(operation2).
… 2. (non-public)ClassBooking’sconstructor, amongitsotheractions
„ makesa one-directionallink backto theinstance
of PassengerRole
„ makesa one-directionallink to theinstance
of SpecificFlight
„ callsoperations
3 and4.
… 3. (non-public)Theinstance of SpecificFlight
„ makesa one-directionallink to theinstance
of Booking.
… 4. (non-public)Theinstance of PassengerRole
„ makesa one-directionallink to theinstance
of Booking.

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Airplane
SpecificFlight * 0..1

Classcollaboration‘d’ + changeAirplane [d1]


addLinkToSpecificFlight [a2, d3]
deleteLinkToSpecificFlight [d2]

… Changingthedestination
ofalink
… e.g. changing
theAirplane of to a SpecificFlight , from
airplane 1 to airplane 2
… 1. (public)Theinstance
of SpecificFlight
„ deletesthelink to airplane 1
„ makesa one-directionallink to airplane 2
„ callsoperation2
„ thencallsoperation3.
… 2. (non-public)airplane 1
„ deletes itsone-directionallink to theinstance
of SpecificFlight .
… 3. (non-public)airplane 2
„ makes a one-directionallink to theinstance
of SpecificFlight .

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


EmployeeRole SpecificFlight
* *
+ getName [e2] crewMember + findCrewMember [e1]
Classcollaboration‘e’
… Searching
foranassociated
instance
… e.g. searchingfor a crew memberassociated
with a
SpecificFlight thathasacertainname
.

… 1. (public)Theinstance
of SpecificFligh t
„ createsan Iterator over all the crewMemberlinks of the
SpecificFlight \
„ for eachof themcalloperation2, untilit findsamatch
.
… 2. (may be public) The instanceof EmployeeRole
returnsitsname
.

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Hari Prasad Pokhrel (hpokhrel24@gmail.com)
Packages in Class Diagrams
… Complex Class Diagrams are Abstracted
… Packages Contain Multiple Classes and are Associated a
Linked to One Another
† Dependency Arrow is Dashed
† Indicates that One Package Depends on Another
† Means that Changes in Destination (Dependee
- Arrow Head)
Can Possible Force Changes in the Source (Dependent
–Arrow
Tail)\
… Supports Rudimentary SW Architecture Concepts
… However, no Checking/Enforcement of Dependencies in
Subsequent Diagrams

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Package
… A package
is a general purpose mechanism for organizing
elements into groups.
… Packages help you organize the elements in your models s
you can more easily understand them.
… Packages also let you control access to their contents so th
can control the seams in your system's architecture.

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Simple and Extended Package

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Package
… A package may own other elements, including classes, interface
components, nodes, collaborations, use cases, diagrams, and ev
other packages.
… A package forms a namespace, which means that elements of th
same kind must be named uniquely within the context of its encl
package.
† For example, you can't have two classes
Queue
named
owned by the
same package, but you can have a class
Queue
named
in packageand P1
another (and different) class named
Queue in package. P2
† The classes
P1::Queue and P2::Queue are, in fact, different
classes and
can be distinguished by their path names.
† Different kinds of elements may have the same name.
… Packages may own other packages
Hari Prasad Pokhrel (hpokhrel24@gmail.com)
Packages may own other packages

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Importing and Exporting
The public parts of a package
are called itsexports.
The package
GUI exports two classes,
Window and Form.
EventHandleris not exported by
GUI;
EventHandleris a protected part
of the package.

In this example,Policiesexplicitly importsthe package GUI.GUI::Window and


GUI::Form are therefore made visible to the contents of the package Policies.
However,GUI::EventHandleris not visible because it is protected.
Because the package Serverdoesn't import GUI, the contents Serverdon't
of have
permission to access any of the contents of GUI.
Similarly, the contents of GUI don't have permission to access any of the contents o
Server.
Generalization Among Packages

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Modeling Groups of Elements

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Modeling Architectural Views

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Example Package

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Static: Component Diagram
… Component Diagram:
High-Level Interaction and
Dependencies Among Software Components
… Captures the Physical Structure of the Implementation
… Built As Part of Architectural Specification
… Purposes:
† Organize Source Code
† Construct an Executable Release
† Specify a Physical Database
… Main Concepts:
Component, Interface, Dependency,
Realization
… Developed by Architects and Programmers

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Component
y A component
is a physical and replaceable part of a system th
conforms to and provides
realization
the of a set of interfaces.
y Graphically, a component is rendered as a rectangle with
tabs.

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Components and Classes
… In many ways, components are like classes: Both have names; b
may realize a set of interfaces; both may participate in dependen
generalization, and association relationships; both may be neste
both may have instances; both may be participants in interaction
However, there are some significant differences between compo
and classes.
† Classes represent logical abstractions; components represent
physical things that live in the world of bits. In short, componen
may live on nodes, classes may not.
† Components represent the physical packaging of other logica
components and are at a different level of abstraction.
† Classes may have attributes and operations directly. In genera
components only have operations that are reachable only thro
their interfaces.
Hari Prasad Pokhrel (hpokhrel24@gmail.com)
Components and Classes
… A component is the physical implementation of a set of other logical elements
as classes and collaborations
… shows, the relationship between a component and the classes it implements
shown explicitly by using a dependency relationship.

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Components and Interfaces
An interfaceis a collection of operationsthat are usedto specify a
service of a class or a component . The relationship between
componentandinterfaceis important.
All themost
common component -based
operating system facilities
(such as COM+, CORBA,
andEnterprise JavaBeans)
use interfaces as the glue
that binds components
together.
Hari Prasad Pokhrel (hpokhrel24@gmail.com)
Kinds of Components
… Deployment components.
† These are the components necessary and sufficient to form an executa
system, such as dynamic libraries (DLLs) and executables (EXEs).
… Work product components.
† These components are essentially the residue of the development proce
consisting of things such as source code files and data files from which
deployment components are created. These components do not directly
participate in an executable system but are the work products of
development that are used to create the executable system.
… Execution components.
† These components are created as a consequence of an executing syste
such as a COM+ object, which is instantiated from a DLL.

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Hari Prasad Pokhrel (hpokhrel24@gmail.com)
Modeling Executables and Libraries
… To model executables and libraries,
… Identify the partitioning of your physical system.
… Model any executables and libraries as components, usin
the appropriate standard elements
… If it's important for you to manage the seams in your syste
model the significant interfaces that some components us
and others realize.
… As necessary to communicate your intent, model the
relationships among these executables, libraries, and
interfaces.

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Hari Prasad Pokhrel (hpokhrel24@gmail.com)
Modeling Tables, Files, and Documents

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Modeling an API
y An API is essentially an interface that is realized by one or more
components. As a developer, you'll really care only about the inte
itself; which component realizes an interface's operations is not
relevant as longsome
as component realizes it.

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Modeling Source Code

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Component Diagram
y Captures the Physical Structure of the Implementation

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Static: Deployment Diagram
… Deployment Diagram:
Focus on the Placement and Configuration of
Components at Runtime
… Captures the Topology of a System’s Hardware
… Built As Part of Architectural Specification
… Purposes:
† Specify the Distribution of Components
† Identify Performance Bottlenecks
… Main Concepts:
Node, Component, Dependency, Location
… Developed by Architects, Networking Engineers, and
Engineers
System
… Focus is on physical aspects of a system.

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Node
y A node is a physical element that exists at run time and
represents a computational resource, generally having at
some memory and, often processing capability.
y A node typically represents
processor
a or a device
on which
components may be deployed

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Deployment Diagram
y Captures the Topology of a System’s Hardware

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Deployment Diagram
… Deploy Components onto Nodes

HospitalServer:Host
BloodAnalyzer
(COTS) PatientRec
Analyzer update DBMS

TechnicianPC:PC
LabAnalyzer
results
Hari Prasad Pokhrel (hpokhrel24@gmail.com)
Nodes and Components
… Components
are things
that participate in the
execution of a system;
nodesare things that
execute components.

… Components
represent the
physical packaging of
otherwise logical
elements;
nodesrepresent
the physical deployment of
components.
Hari Prasad Pokhrel (hpokhrel24@gmail.com)
Connections
… The most common kind of
relationship you'll use among
nodes is an association.
… In this context, an association
represents a physical connection
among nodes, such as an Ethernet
connection, a serial line, or a
shared bus, as Figure shows

y You can even use associations to model indirect


connections, such as a satellite link between
distant processors.
Hari Prasad Pokhrel (hpokhrel24@gmail.com)
Combining
Component and Deployment Diagrams

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Modeling Processors and Devices
… Because all of the UML's extensibility mechanisms apply
nodes, you will often stereotypes
use to specify new kinds of
nodes that you can use to represent specific kinds of
processors and devices.
… A processor
is a node that has processing capability, meaning
can execute component.
a
… A device
is a node that has no processing capability (at leas
that are modeled
at this level of abstraction) and, in general,
represents something that interfaces to the real world.

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Hari Prasad Pokhrel (hpokhrel24@gmail.com)
Modeling the Distribution of
Components.

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Dynamic: Interaction Diagrams
y A series of diagrams describing
dynamic
the behavior
of an
object-oriented system.
y A set of messages exchanged among a set of objects within
context to accomplish a purpose.
y Often used to model the way a use case is realized throug
sequence of messages between objects.
y Interaction diagrams are used for capturing dynamic natu
of a system

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Dynamic: InteractionDiagrams (Cont.)
y The purpose of Interaction diagrams is to:
y Model interactions between objects
y Assist in understanding how a system (a use case) actually w
y Verify that a use case description can be supported by the
existing classes
y Identify responsibilities/operations and assign them to classe

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Interaction Diagrams (Cont.)
y UML
y Collaboration Diagrams
y Emphasizes structural relations between objects
y Sequence Diagram
y Sequence diagrams are used to capture time ordering of message flo

Generally a set of sequence and collaboration diagrams are u


to model an entire system

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Two kinds of UML Interaction Diagrams

y SequenceDiagrams: show object interactions arranged in


time sequence,
vertically
y Communication Diagrams: show object interactions
arranged as a flow of objects and their links to each other,
numerically
y Semantically equivalent, structurally different
y Sequence diagram emphasize time ordering
y Communication diagrams make object linkages explicit

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Interaction and Message
An interactionis a behavior that comprises a set of messages, excha
among a set of objects, to accomplish a specific purpose.

A messageis the specification of a communication between objects th


conveys information, with the expectation that some kind of activity
ensue (follow).

From the name


Interaction
it is clear that the diagram is used to describe
some type of interactions among the different elements in the mod

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Interaction..
y This interactive behavior is represented in UML by two diagram
known as
Sequence diagram
andCollaboration diagram.

y Sequence diagram emphasizes on time sequence of message


collaboration diagram emphasizes on the structural organizatio
the objects that send and receive messages

y The purposes of interaction diagrams are to visualize the


interactive behavior of the system

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Interaction..
y So the purposes of interaction diagram can be describes
y To capture dynamic behavior of a system.
y To describe the message flow in the system.
y To describe structural organization of the objects.
y To describe interaction among objects.

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Dynamic: Sequence Diagram
… Sequence Diagram:
For a Task, Indicates the Object Interactions
Over Time that are Needed
… Captures Dynamic Behavior -oriented)
(Time
… Purposes:
† Model Flow Of Control
† Illustrate Typical Scenarios
† Provide Perspective on Usage an Flow
… Main Concepts:
Interaction, Object, Message, Activation
… Notes:
† Dynamic Diagrams are Complementary
† Provide Contrasting Perspectives of “Similar” Information and
Behavior

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Sequence Diagram
A sequencediagramis an interaction diagram that emphasizes
the time ordering of messages.

A lifelineis a vertical dashed line that represents the lifetime


an object.

A focus of control is
tall,
a thin rectangle
that shows the period
of time during which an object is performing an action.

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Sequence Diagram Notation

c: Client : Ticket Agent

«create»
setItinerary(i)

calculateRoute()
route

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Types of Messages
y Synchronous (flow interrupt until the message has
completed.

y Asynchronous (don’t wait for response)

y Flat– no distinction between sysn/async

y Return– control flow has returned to the caller.

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


y Create message
y A create message represents the creation of an instance in an interaction. The create message is
represented by the keyword
«create».
The target lifeline begins at the point of the create message.
y Destroy message
y A destroy message represents the destruction of an instance in an interaction. The
s destroy messa
represented by the keyword
«destroy».
The target lifeline ends at the point of the destroy message, and i
denoted by an X.
y Synchronous call message
y Synchronous calls, which are associated with an operation, have a send and receive
e ismessage. A
sent from the source lifeline to the target lifeline. The source lifeline is blocked ations
from other oper
until it receives a response from the target lifeline.
y Asynchronous call message
y Asynchronous calls, which are associated with an operation, typically have only a can
send message,
also have a reply message. In contrast to a synchronous message, the source lifeline
from is not block
receiving or sending other messages. You can also move the send and receive points elay individually
the time between the send and receive events. You might choose to do this if a response
- is not tim
sensitive or order
- sensitive.
y Asynchronous signal message
y Asynchronous signal messages, are associated with a signal. A signal differs from
there
a message in t
is no operation associated with the signal. A signal can represent an interrupt orToerror condition.
specify a signal, you create an asynchronous call message and change the type inies the message
view.
Hari Prasad Pokhrel (hpokhrel24@gmail.com)
Synchronous and Asynchronous Calls

¾If a caller sends saynchronous message, it must wait


until the message is done, such as invoking a subroutine.
¾If a caller sends an
asynchronous message, it can
continue processing and doesn’t have to wait for a respon
¾You see asynchronous calls in multithreaded application
and in message
-oriented middleware.
¾Asynchrony gives better responsiveness and reduces th
Hari Prasad Pokhrel (hpokhrel24@gmail.com)
temporal coupling but is harder to debug.
Sequence diagrams
y Some control information can also be included.
y Two types of control information are particularly valuable:
y A condition(e.g. [invalid] or [OK] ) indicates that a message is
only if the condition is true.
y An iteration (*) marker shows the message is sent many time
multiple receiver objects as would happen when a collection
elements of an array are being iterated. The basis of the itera
also be indicated e.g. [for every book object].

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Sequence diagrams

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Lifeline box

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Messages

The first message doesn’t have a participant that sent it, as it comes f
an undetermined source. It’s called
found
a message.
Hari Prasad Pokhrel (hpokhrel24@gmail.com)
Reply or Returns

•Using the messagesyntax returnVar = message(parameter) .


•Using a reply (or return) messageline at the end of an activation bar.
Hari Prasad Pokhrel (hpokhrel24@gmail.com)
Messages to "self" or "this"

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Creation of Instances

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Object Lifelines and Object Destruction

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Diagram Frames

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Conditional Messages

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Mutually Exclusive Conditional
Messages

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Nesting of frames.

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


The first message doesn’t have a participant that sent it, as
it comes from an undetermined source. It’s called
found
a
message
Hari Prasad Pokhrel. (hpokhrel24@gmail.com)
Sequence diagram for book renew use
case.

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Sequence diagram for car parking

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Sequence diagram ofmakePayment
use case

The sequence diagram shown in Figure makePaymentis read as follows:


1. The messagemakePaymentis sent to an instance of aRegister. The sender is not identified.
2. The Registerinstance sends themakePaymentmessage to aSaleinstance.
3. The Saleinstance creates an instance of Payment
a .

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Sequence

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Sequence Diagram
y Captures Dynamic Behavior -Oriented)
(Time

Hari Prasad Pokhrel (hpokhrel24@gmail.com)


Sequence Diagram

Hari Prasad Pokhrel (hpokhrel24@gmail.com)

Вам также может понравиться