0% found this document useful (0 votes)
18 views113 pages

OOSD Module 2

Uploaded by

Nivedita Tiwari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views113 pages

OOSD Module 2

Uploaded by

Nivedita Tiwari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 113

Name of Institution

Object-Oriented Systems Design

B.Tech Computer Science & Engineering


VII Semester (2017-21)

CSE431
Dr. Bramah Hazela

1
Name of Institution

Module II
Systems modelling using the object oriented
approach and UML

2
Descriptors/Topics Name of Institution

• Elaboration - Domain Models


• Finding conceptual classes and description
classes
• Associations – Attributes – Domain model
refinement
• Finding conceptual class hierarchies-
Aggregation and Composition-
• UML activity diagrams and modeling,
• Scenario based examples for system
modeling using object oriented approach.
3
Why do this? Name of Institution

• If you don’t understand the domain, you


can’t program for it effectively
• Lower the representational gap between
mental model and software model

4
Objectives Name of Institution

• Identify conceptual classes related to the


current iteration
• Create an initial domain model
• Model appropriate attributes and
associations

5
What is a Domain Model?
Name of Institution

• Illustrates noteworthy concepts in a


domain. That is, defines what the
system is about
• Models the things in your system and
the way they relate to each other
• A domain model is conceptual, not a
software artifact
• A visual dictionary

6
What’s the Difference? Name of Institution

Conceptual Class:
Software Artifacts:
Sale SalesDatabase

amt
Sale
item
Double amt;
Item item;
void print()
7
Business Object Model Name of Institution

• Class diagrams with no methods, just


fields
• May show domain objects
• Associations between classes
• Attributes of conceptual classes

8
Domain Model, visually Name of Institution

9
Conceptual Classes Name of Institution

• An idea, thing, or object


• Symbol—Words or images representing
a conceptual class
• Intension—Definition of a conceptual
class
• Extension—The set of examples to
which the class applies
• It is not a data model

10
How to Create a Domain ModelName of Institution

• Find the conceptual classes


• Draw them as classes in a UML class
diagram
• Add associations necessary to record
relationships
• Add attributes necessary for information
to be preserved
• Use existing names, the vocabulary of
the domain
11
How do I find Conceptual Classes?Name of Institution

• Reuse or modify existing models. If


there are published models, prior art, or
books, use them
• Use a category list (Table 9.1)
• Identify noun phrases (linguistic
analysis)

12
Noun Phrase Identification Name of Institution

• Consider the following problem description,


analyzed for Subjects, Verbs, Objects:
The ATM verifies whether the customer's card number and PIN are correct.
S V O O O
If it is, then the customer can check the account balance, deposit cash, and withdraw
cash.
S V O V O
V O
Checking the balance simply displays the account balance.
S O V O
Depositing asks the customer to enter the amount, then updates the account balance.
S V O V O V O
Withdraw cash asks the customer for the amount to withdraw; if the account has
enough cash,
S O V O O V S
V O
the account balance is updated. The ATM prints the customer’s account balance on a
receipt.
O V S V O
O
CS6359 Fall 2012 John Cole 13
Noun Phrases Name of Institution

Analyze each subject and object as


follows:
• Does it represent a person performing an
action? Then it’s an actor, ‘R’.
• Is it also a verb (such as ‘deposit’)? Then it
may be a method, ‘M’.
• Is it a simple value, such as ‘color’ (string) or
‘money’ (number)?
Then it is probably an attribute, ‘A’.
• Which NPs are unmarked? Make it ‘C’ for
class.
Verbs can also be classes, for example:
• Deposit is a class if it retains state information
14
Where are the Terms?
Name of Institution

• Some are in the use case


• Some come from domain experts
• Natural language is imprecise and
ambiguous, so you need to use
judgment

15
POS example Name of Institution

You can create a list, or you can use a set of class diagrams, per the table
below

Register Item Store Sale

Sales
Cashier Customer Manager
LineItem

Product Product
Payment
Catalog Specification

16
Classes Name of Institution

A class is a description of a set of


<ClassName> objects that share the same attributes,
operations, relationships, and semantics.

<Class Attributes> Graphically, a class is rendered as a


rectangle, usually including its name,
attributes, and operations in separate,
<Class Behaviors> designated compartments.
Class Names Name of Institution

The name of the class is the only required tag in the


ClassName graphical representation of a class. It always
appears in the top-most compartment.

attributes

operations
Class Attributes Name of Institution

Person

An attribute is a named property of a


name : String class that describes the object being modeled.
address : Address In the class diagram, attributes appear in
birthdate : Date the second compartment just below the
ssn : Id name-compartment.
Class Attributes (Cont’d) Name of Institution

Attributes are usually listed in the form:

Person attributeName : Type

A derived attribute is one that can be


computed from other attributes, but
name : String doesn’t actually exist. For example,
address : Address a Person’s age can be computed from
birthdate : Date his birth date. A derived attribute is
/ age : Date designated by a preceding ‘/’ as in:
ssn : Id
/ age : Date
Class Attributes (Cont’d) Name of Institution

Person

Attributes can be:


+ public
+ name : String
# protected
# address : Address
- private
# birthdate : Date
/ derived
/ age : Date
- ssn : Id
Class Operations Name of Institution

Person

name : String
address : Address
birthdate : Date
ssn : Id

Operations describe the class behavior


eat and appear in the third compartment.
sleep
work
play
Class Operations (Cont’d) Name of Institution

PhoneBook

newEntry (n : Name, a : Address, p : PhoneNumber, d : Description)


getPhone ( n : Name, a : Address) : PhoneNumber

You can specify an operation by stating its signature: listing the name, type, and
default value of all parameters, and, in the case of functions, a return type.
Depicting Classes Name of Institution

When drawing a class, you needn’t show attributes and operation in every
diagram.

Person Person
Person

name : String
birthdate : Date
Person ssn : Id

name Person eat()


address sleep()
birthdate work()
eat play()
play
Class Responsibilities Name of Institution
A class may also include its responsibilities in a class diagram.

A responsibility is a contract or obligation of a class to perform a particular


service.

SmokeAlarm

Responsibilities

-- sound alert and notify guard station


when smoke is detected.

-- indicate battery state


Mapping of Use Case to Class Name of Institution

Use Case Class


Control Entity Boundary
Enter Bill Details BillDetailAcceptor Clerk Product, Bill
Calculate Total TotalAmountCalculator Bill
Amount
Print Bill BillPrinter Clerk Bill
How to Identify Behaviors Name of Institution

Class Behavior

BillDetailAcceptor ValidateBillDetail()

Clerk EnterBillDetail

Product

TotalAmountCalculator calculateTotalAmount()

BillPrinter PrintBill()

Bill addProductDetail(),editProductDetail()
,deleteProductDetail()
How to Identify Attributes Name of Institution

Class Attributes

BillDetailAcceptor

Clerk clerkCode,clerkName

Product productCode,productName and


unitPrice
TotalAmountCalculator

BillPrinter

Bill billNo.product and quantityBought


Relationships Name of Institution

In UML, object interconnections (logical or physical),


are
modeled as relationships.

Kinds of relationships in UML:

• Dependencies
• Associations
• Aggregation
• Composition
• Generalization
Dependency Relationships Name of Institution

A dependency indicates a semantic relationship between two or


more elements. The dependency from CourseSchedule to Course exists
because Course is used in both the add and remove operations of
CourseSchedule.

CourseSchedule

Course

add(c : Course)
remove(c : Course)
Generalization Relationships
Name of Institution

Person
A generalization connects a subclass
to its superclass. It denotes an
inheritance of attributes and behavior
from the superclass to the subclass and
indicates a specialization in the subclass
of the more general superclass.

Student
Generalization Relationships (Cont’d)
Name of Institution

UML permits a class to inherit from multiple superclasses, although some


programming languages (e.g., Java) do not permit multiple inheritance.

Student Employee

TeachingAssistant
Association Relationships Name of Institution

If two classes in a model need to communicate with each other, there must be
link between them.

An association denotes that link.

Student Instructor
Association Relationships (Cont’d) Name of Institution

We can indicate the multiplicity of an association by adding multiplicity


adornments to the line denoting the association.

The example indicates that a Student has one or more Instructors:

Student Instructor
1..*
Association Relationships (Cont’d)
Name of Institution

The example indicates that every Instructor has one or more Students:

Student Instructor
1..*
Association Relationships (Cont’d)
Name of Institution

We can also indicate the behavior of an object in an association (i.e., the role
of an object) using rolenames.

teaches learns from


Student Instructor
1..* 1..*
Association Relationships (Cont’d)Name of Institution

We can also name the association.

membership
Student Team
1..* 1..*
Association Relationships (Cont’d)
Name of Institution

We can specify dual associations.

member of

1..* 1..*
Student Team

1 president of 1..*
Association Relationships (Cont’d)Name of Institution

We can constrain the association relationship by defining the navigability of


the association. Here, a Router object requests services from a DNS object by
sending messages to (invoking the operations of) the server. The direction of
the association indicates that the server has no knowledge of the Router.

Router DomainNameServer
Association Relationships (Cont’d)Name of Institution

Associations can also be objects themselves, called link classes or an


association classes.

Registration

modelNumber
serialNumber
warrentyCode

Product Warranty
Association Relationships (Cont’d)
Name of Institution

A class can have a self association.

nex
t
LinkedListNode
previous
Association Relationships (Cont’d)
Name of Institution

We can model objects that contain other objects by way of special


associations called aggregations and compositions.

An aggregation specifies a whole-part relationship between an aggregate (a


whole) and a constituent part, where the part can exist independently from
the aggregate. Aggregations are denoted by a hollow-diamond adornment
on the association.

Engine
Car
Transmission
Association Relationships (Cont’d)Name of Institution

A composition indicates a strong ownership and coincident lifetime of parts


by the whole (i.e., they live and die as a whole). Compositions are denoted
by a filled-diamond adornment on the association.

Scrollbar
1 1

Window Titlebar
1 1

Menu
1 1 .. *
Description Classes Name of Institution

• A description class contains information


that describes something else
• E. g. Product Description records the
price, picture, text description (and what
else?) of an item

44
Conceptual Data Model Name of Institution

The three stages of Data Model are:


• Conceptual
• Logical
• Physical

Elements of the Business Models, Use-Case Model, and


Analysis Model that can be used to define the initial
Conceptual Data Model for persistent data in the system

45
Conceptual Data Model Elements Name of Institution

The following sections describe the elements of the


Business Models, Use-Case Model, and Analysis Model
that can be used to define the initial Conceptual Data
Model for persistent data in the system.

• Business Models
Business Use Case Models
Business Analysis Models
• Requirements and Analysis Model
• System USE-Case Model
• Analysis Model

46
Principles Name of Institution

• Main approach – object-oriented


– Class (entity set, object)
– Association (relationship, relation)
– Data member (attribute, property)
– Instance (entity, occurrence)

47
Languages Name of Institution

• Entity Relationship model (E-R) (ERM)


– Entity set
– Relationship
– Attribute

48
Languages Name of Institution

• MERISE
– Object with occurrences
– Relation
– Propertiy

ENROLL

STUDENT SUBJECT
-Name
-Name
-Address IS GIVEN
TEXTBOOK

49
Languages Name of Institution

• Object Role Modeling (ORM)

50
Languages Name of Institution

• Class Diagram
– Class with instances
– Association
– Property

STUDENT
+enrolls +is enrolled SUBJECT
+Name
+FamilyName +SubName
+Address * *

51
Conceptual Model Name of Institution

• Goals
– Starting from the dictionary and the rules this model tries to
reveal the relations among the data and their interaction
• Example – School
Rules Dictionary
1. Every class has a one and only Student’s Address,
one room. Subject,
2. Every subject is teaches by only Number of Hours,
one teacher. Class Name,
3. Every class is taught a subject a Student's Family Name,
fixed number of hours. Teacher‘s Name,
4. Every student can have no more Mark,
one mark in every subject. Room Number,
5. The school manages the Student’s Name
timetable and the rating of
students and teachers..

52
Concepts Name of Institution

• Class (Entity class, Entity instance)


• Association
– Relationship between entity instances
• Attribute
– Properties

53
Defining an Entity ClassName of Institution

• Give it a name (a noun)


• Define its attributes
• Define the rules
– What belongs to the class?
– How the instances are identified in the class?
• Identifying an instance (Identifier)
NAME STUDENT
1.First Name
1.Attribute 2.Last Name
2.Attribute 3.Address

54
Association Name of Institution

• Give a name (a verb)


• Determine the
participating classes
• Define the cardinalities

55
Examples Name of Institution

56
Identifier of an Association
Name of Institution

57
Cardinalities of an Association
Name of Institution

• Cardinalities One to
One
– 0..1 – 0..1 – Every
student can use one
locker

– 0..1 – 1

– 1 – 1 Every student
uses a locker and ther
are no free lockers

58
Cardinalities of an Association
Name of Institution

• Cardinalities One to
Many
– 1 – 1..N

– 0..1 – 1..N

– 1 – 0..N

– 0..1 – 0..N
59
Cardinalities of an Association
Name of Institution

• Cardinalities Many to
Many
– 1..N – 1..N

– 0..N – 1..N

– 0..N – 0..N

60
Cardinalities of an AssociationName of Institution

• Generalization
– Minimal cardinality
• Mandatory participation of every instance - 1
• Optionally participation of every instance - 0
– Maximal cardinality
• To only one instance of the other class – 1
• To multiple instances of the other class - N

61
Dimension of an Association
Name of Institution

• Number of different classes participating in it


• Multidimensional

Make cours
-HourNumber

-End4 -End3
TEACHER * * SUBJECT
-TeacherName -SubName
-End5
*

ROOM
-RoomNo

62
Dimension of an Association
Name of Institution

• Multidimensional

63
Dimension of an Association
Name of Institution

• One-dimensional
(Reflexive)

64
Aggregate Associations Name of Institution

• Aggregation

• Composition

65
Weak Entities Name of Institution

• It is identified through the association

66
Recommendations Name of Institution

• Don’t use high dimension associations


• Be aware not replace classes by associations

67
Case Study – Management Rules
Name of Institution

1. A patient is characterized by: 6. Each specialist has one or more


– Unique Number
specialties
– Name 7. Each specialist can give
– address consultations in one or more
policlinics
– Phone Number
8. Each policlinic groups several
2. General practitioner is specialists
characterized by:
– Serial Number 9. A patient can make an appointment
– Name
for a consultation with specialist in a
given policlinic, The specialist must
– Phone Number work in this policlinic
3. Each patient is supervised by a GP 10. The appointment is for a date that is
4. A policlinic is characterized by: later than the date of appointment
– Name 11. If the consultation does not take
– Address place a new appointment must be
– Phone Number made no matter what are reasons for
5. A specialist is characterized by: the failure
– Serial Number 12. Lists of appointment for every
– Name specialist are made at the beginning
– Phone Number of the day.
13. In the end of every day two reports
are made:
– A log of appointment made
– A log of consultations done
68
Case Study - Policlinic Name of Institution

69
Case Study - Policlinic Name of Institution

70
Subtypes Name of Institution

• Example – Hardware
components order

71
Subtypes Name of Institution

72
Activity Diagram Name of Institution

• Describe the Dynamic aspects of the


system.
• Purpose of Activity Diagram
• Where to Use Activity Diagram
• How to Draw an Activity Diagram

73
Activity Diagram Name of Institution

• Describes how activities are coordinated.

• Is particularly useful when you know that an operation has


to achieve a number of different things, and you want to
model what the essential dependencies between them are,
before you decide in what order to do them.

• Records the dependencies between activities, such as


which things can happen in parallel and what must be
finished before something else can start.

• Represents the workflow of the process.


Activity Diagram Name of Institution

• Activity diagrams describe the workflow behavior of a system.

– Activity diagrams are used in process modeling and analysis of during


requirements engineering.

– A typical business process which synchronizes several external incoming events


can be represented by activity diagrams.

• They are most useful for understanding work flow analysis of synchronous
behaviors across a process.

75
Activity Diagram Name of Institution

• Activity diagrams are used for


– documenting existing process
– analyzing new Process Concepts
– finding reengineering opportunities.

• The diagrams describe the state of activities by showing the


sequence of activities performed.
– they can show activities that are conditional or parallel.

76
Activity Diagram ConceptsName of Institution

• An activity is trigged by one or more events and activity may result in one or
more events that may trigger other activity or processes.

• Events start from start symbol and end with finish marker having activities in
between connected by events.

• The activity diagram represents the decisions, iterations and parallel/random


behavior of the processing.
– They capture actions performed.
– They stress on work performed in operations (methods).

77
Name of Institution
When to Use Activity Diagrams
• The main reason to use activity diagrams is to model the workflow
behind the system being designed.

• Activity Diagrams are also useful for:


– analyzing a use case by describing what actions need to take place and
when they should occur
– describing a complicated sequential algorithm
– modeling applications with parallel processes

• Activity Diagrams should not take the place of interaction diagrams


and state diagrams.

• Activity diagrams do not give detail about how objects behave or how
objects collaborate.

78
Components Name of Institution

• An activity is an ongoing, though interruptible,


execution of a step in a workflow (such as an
operation or transaction)
– Represented with a rounded rectangle.
– Text in the activity box should represent an activity
(verb phrase in present tense).

79
Components Name of Institution

• An event is triggered by an activity. It specifies a significant occurrence that has a


location in time and space.
– An instance of an event (trigger) results in the flow from one activity to another.
– These are represented by directed straight lines emerging from triggering activity and
ending at activity to be triggered. Label text for events should represent event but not the
data involved.

• A decision may be shown by labeling multiple output transitions of an activity with


different guard conditions.
– For convenience a stereotype is provided for a decision: the traditional diamond shape, with
one or more incoming arrows and with two or more outgoing arrows, each labeled by a
distinct guard condition with no event trigger.

80
How to Draw an Activity Diagram Name of Institution

• Diagrams are read from top to bottom and have branches and forks to
describe conditions and parallel activities.
– A fork is used when multiple activities are occurring at the same time.

– A branch describes what activities will take place based on a set of


conditions.

– All branches at some point are followed by a merge to indicate the end of
the conditional behavior started by that branch.

– After the merge all of the parallel activities must be combined by a join
before transitioning into the final activity state.

81
Activity Diagram Example
Name of Institution
Start State
Activity
Fork

Branch

Merge Join

End State

82
Use Case Name of Institution

• Withdraw money from a bank account


through an ATM

83
Name of Institution

84
Notation Name of Institution

2. Transition

Activity1()c Activity2()

1. Activities
Notation - 2 Name of Institution

[x>0]
[x>0]

Activity1()c
[x=0] [x=0]
[x<0] [x<0]

3. Decision Diamond
Name of Institution

Notation - 3

4.1 Synch. Bar (Join) 4.2 Splitting Bar (Fork)

{AND}
{OR}
{XOR}
Notation - 3 Name of Institution

Start Marker Stop Marker

5. Start & Stop Markers


Notation - 4 Name of Institution

Developers Testers Markers

Swimlane Swimlane Swimlane

Application/Department/Group/Role Boundaries
Example: Business Level Activity Diagram
of the Library Name of Institution

member Librarian
[borrower]
Find book on shelf

[returning]
[returner]
Wait in queue
[borrowing]

Record return Put book back of shelf

Record borrowing

Prepare for next


member
Activity Diagrams (1) Name of Institution

• To model the dynamic aspects of a system


• It is essentially a flowchart
– Showing flow of control from activity to activity

• Purpose
– Model business workflows
– Model operations
Activity Diagrams (2) Name of Institution

• Activity diagrams commonly contain


– Activity states and action states
– Transitions
– Objects
Action States and Activity StatesName of Institution

• Action states are atomic and cannot be


decomposed
– Work of the action state is not interrupted

• Activity states can be further decomposed


– Their activity being represented by other activity
diagrams
– They may be interrupted
Transitions (1) Name of Institution

• When the action or activity of a state


completes, flow of control passes
immediately to the next action or activity state
• A flow of control has to start and end
someplace
– initial state -- a solid ball
– stop state -- a solid ball inside a circle
Transitions (2) Name of Institution
Activity Diagram: Example (1)
Name of Institution
Branching (1) Name of Institution

• A branch specifies alternate paths


taken based on some Boolean
expression
• A branch may have one incoming
transition and two or more outgoing
ones
Branching (2) Name of Institution
Activity Diagram: Example (2)
Name of Institution
Forking and Joining Name of Institution

• Use a synchronization bar to specify


the forking and joining of parallel flows
of control
• A synchronization bar is rendered as a
thick horizontal or vertical line
Fork Name of Institution

• A fork may have one incoming transitions and


two or more outgoing transitions
– each transition represents an independent flow of
control
– conceptually, the activities of each of outgoing
transitions are concurrent
• either truly concurrent (multiple nodes)
• or sequential yet interleaved (one node)
Join Name of Institution

• A join may have two or more incoming


transitions and one outgoing transition
– above the join, the activities associated with each
of these paths continues in parallel
– at the join, the concurrent flows synchronize
• each waits until all incoming flows have reached the
join, at which point one flow of control continues on
below the join
Fork Name of Institution
Activity Diagram: Example Name
(3) of Institution
Activity Diagram: Example (4)
Name of Institution
Activity Diagram: Example (5)
Name of Institution
Name of Institution

Activity Diagram: Example (6)


Activity Diagram: Example (7) Name of Institution
Swimlanes (1) Name of Institution

• A swimlane specifies a locus of activities


• To partition the activity states on an activity
diagram into groups
– each group representing the business organization
responsible for those activities
– each group is called a swimlane
• Each swimlane is divided from its neighbor
by a vertical solid line
Swimlanes (2) Name of Institution

• Each swimlane has a name unique within its


diagram
• Each swimlane may represent some real-world
entity
• Each swimlane may be implemented by one or
more classes
• Every activity belongs to exactly one swimlane,
but transitions may cross lanes
Activity Diagram: ExampleName
(8)of Institution
Activity Diagram: Example (9)
Name of Institution
Disadvantages Name of Institution

• A disadvantage of activity diagrams is that they do not explicitly present which


objects execute which activities, and the way that the messaging works
between them.
– Labeling of each activity with the responsible object can be done.
– It is useful to draw an activity diagram early in the modeling of a process, to help
understand the overall process.

• Then interaction diagrams can be used to help you allocate activities to classes.

113

You might also like