You are on page 1of 18

OOSE BCA SEM IV

Object Oriented Design – Unit 5 –PART II


Subject Material

Contents In this unit:


o Steps of object-oriented design, Creating design diagrams:
o Interaction diagrams, Sequence diagrams, Collaboration
diagrams
o Refinement of use case description and classes and relationships
o Identification of operations for implementations
o Detailed class diagram and design document, Generating test
cases from use cases
o Object-oriented design principles for improving software quality
o Moving towards implementation: activity diagrams and state
chart diagrams, storing persistent data in database
o Implementing the classes

Chapter Coverage: Object Oriented Design

Reference Book Singh Y., Malhotra R., Object oriented Software Engineering

Juhi patel UTU Page 1 of 18


OOSE BCA SEM IV

INTRODUCTION
In chapter 2, we saw Object oriented software development life cycle:[ page 44 ].

This lifecycle has four phases which is different from the traditional SDLC.

OO requirement analysis

OO analysis

OO design

OO programming and testing

Purpose of each phase


OO requirement analysis

Capture requirements, create IRD and produce SRS

OO analysis (Static aspect of the system)

Define and analysis of classes and its types

Define and analysis of objects and relationships

Modeling of classes and creating class diagram

OO design (Dynamic aspect of the system)

Refine objects in detail (w.r.t programming languages, databases, communication


protocols)

Implement interactions among objects

Juhi patel UTU Page 2 of 18


OOSE BCA SEM IV
Activity Diagram

» Dynamic aspects of the system are modelled through activity diagram.


» Activity diagram is used
sed to model the working of a process or an operation.
» Activities carried out in a process/workflow or an operation are depicted in activity
diagram.
» Activity diagrams enable
o To visualize, understand and document the flow of activities in an operation or a
process.

» Activity diagrams are used


o To increase the understanding of a business model, a process or a use case.
o To determine the objective for business-related
business e-commerce application.
o To simplify a given operation.
o In sequence diagrams, the interaction amongst objects is represented,
» Whereas activity diagrams depict the steps involved in a process or operation.

Juhi patel UTU Page 3 of 18


OOSE BCA SEM IV

Activities

» An activity represents execution of a step or a steps in a process or an operation.


» Activity may be atomic or may consists of multiple steps.
» An activity either manual or automated is used to complete a given task.
» An activity is represented by an oval-shaped
oval circle with rounded ends

Transition

» Transition represents the path from one activity to another activity.


» It is represented by a directed line.

Juhi patel UTU Page 4 of 18


OOSE BCA SEM IV
Example: To find difference of two numbers

Branching

» Branching is used for making decisions in an activity.


» Branch consists of guard condition used to control which activity should be followed from a set of
alternative activities.
» Boolean expression (guard condition) depicted in brackets is used to take decision about which
alternative path to follow.
» Decision branch
ranch is represented by a diamond with one incoming transition and more than one
outgoing transition
» On each outgoing transition, a guard condition is specified

Example: to find the positive difference of two numbers.

Juhi patel UTU Page 5 of 18


OOSE BCA SEM IV
Modelling
g Concurrency

» In UML, concurrent flows are depicted by


o Synchronization bars to represent fork
o Join of parallel activities
» Fork
o A fork divides the activity into two or more concurrent subactivities.
o The fork consists of one incoming transition and more than one outgoing transition.
» Join
o Join is used to combine the flow of concurrent activities into the next single activity.
o Join combines the two or more concurrent flows when they are completed.
o Join is used for synchronization of concurrent activities.
o A join may have more re than one incoming transition and one outgoing transition.

Example: Activity diagram for addition subtraction and multiplication of two numbers.

Juhi patel UTU Page 6 of 18


OOSE BCA SEM IV
Example: Activity diagram for login use case.

Using Swimlanes

o A swimlane groups all the activities that are carried out by the owner of the swimlane.
o Used to determine which business entity is responsible for carrying out a specific
activity.
o Each swimlane is represented by a unique name.
o Swimlanes are represented by vertical lines that divide
divide each group from its
neighbours.

Juhi patel UTU Page 7 of 18


OOSE BCA SEM IV

Payment Credit card


Customer Vendor Gateway Warehouse
company

Select item

Add to shopping cart

Place order

Receive order

Asks credit card detail

Provides credit
card details
Receives credit
card details
Verifies credit
card details

Confirms order

Gets item

Ships item

Receives item

Sends bill

Juhi patel UTU Page 8 of 18


OOSE BCA SEM IV
Uses of activity diagram
The uses of activity diagram are:

1. For modelling a workflow or process


2. To model a use case
3. To model an operation
1. for modelling a workflow or process
» Steps may be carried out to model a workflow or a process
o Determine the business entities that will participate in the activity diagram
o Identify the initial state with its preconditions and final state with its postconditions.
o Specify the activities that will take place.
o Provide a separate activity diagram for each complete activity.
o Identify decisions and concurrent flows.
o Show changing values of objects in the activity diagram.
2. To model a use case
» Each use case represents functionality of the system
» Depicts flow of use cases by using activity diagram.
» Create an activity diagram of a use case, steps are
o Identify the preconditions and postconditions of the use case.
o Identify the beginning of the use case
o Identify the activity that will take place in the use case.
o Keep the activities simple and understandable

3. To model an operation

» Activity diagram can be created for an operation.


» To model an operation, depicts the flow of activities in an operation as in the case of flow chart.
» Steps to model an operation,
o Identify parameters and return value of an operation
o Identify preconditions and postconditions of an operations
o Determine the detailed set of activities that may take place in an operation
o If necessary, use branching to represent conditions

Juhi patel UTU Page 9 of 18


OOSE BCA SEM IV

Statechart Diagram
Statechart diagram also models dynamic aspects of the system.
This diagram used to model the life cycle of the object, from the time it is created until the
object is destroyed.
In statechart diagram, various states through which an object goes through during its life cycle
are depicted.

Difference between activity diagram and statechart diagram

Activity diagram Statechart diagram

Activity diagram is based on activity. Statechart diagram is based on state.

An activity diagram is used to model the Statechart diagram models the states of an object’s
sequence of activities in a process or an lifetime
operation

States

» A state is one of the conditions that on object may satisfy during its lifetime.
» In the given state, the object may perform some activity or wait for some event to
happen.

Juhi patel UTU Page 10 of 18


OOSE BCA SEM IV
State transition

» The transition causes an object to move from one state to another state.
» State transition is represented by a directed line.

Example:
» In LMS, book is initialized for,
o open for issue (members can get the book issued),
o close for issue(book is already issued)
o expired (not in physical condition to be issued)

» In the UML, state may consists of


o entry action
Entry action takes place when the object enters a given state.
o do activity
The do activity specifies the tasks/activities that must be performed
while in the current state and continue until the state is expired.
o exit action
• Exit action takes place when the object exits from a given state.

State chart diagram of an object of User class for Login

Juhi patel UTU Page 11 of 18


OOSE BCA SEM IV

» Every statechart diagram consists of two special states


Start state
Stop state
Start state specifies the creation of object.
» Stop state signifies the destruction of the object.

Event

» An event is a message that is sent from one object to another object.


» In the state chart diagram, an event can be shown using operation name on the state transition.

Action

» An action is a behaviour that occurs in response to a state transition.


» The actions become the operation of the object.
» All actions are noninterruptable
» All actions are shown along with state transition after the event name is separated by ‘/’
(slash).

Guard condition

» A guard condition is a Boolean expression that tests whether the condition is true or not.
» If the
he condition is true, then the state transition is done, otherwise not.
» Example:
o The book will only be issued to the member if the account is not full.

Juhi patel UTU Page 12 of 18


OOSE BCA SEM IV
Lifecycle of an object

» Statechart diagram model the states through which a single object goes through during its life
cycle.
» When a dynamic object is modelled, essentially three things are specified
States through which the object goes
Events that are triggered for transition from one state to another state
Actions that are performed during the transition of the state.

Creating substates

» Substates are nested inside other states.


» Substates are also referred to as nested states and the outer state is referred to as a superstate
» Example:
o ATM system consists of three basic states
Idle (when no customer transactions are carried out)
Processing (when a customer transaction is being executed)
Switched off (when ATM is out of service or maintenance purpose)

Juhi patel UTU Page 13 of 18


OOSE BCA SEM IV
History state can be specified in a superstate.
» History state enables the control to remember the point in last activity state.
» History state is depicted by an H inside the small circle.
» Example:
o A process consists of four states : ready, running, waiting and terminated.
o Running superstate has three substates : initializing, executing and exiting.
o If a process is interrupted in between execution, the control must remember last active
state
o When action of waiting state is performed, the control returns to the history state of
running superstate.

» Advantages of state transition(statechart) diagram


o Modelling the objects where states are important.
o Modelling complicated sequence of events

Example:
Consider University Registration System. The students are registered in the beginning of each
semester. The registration must be completed by the students within 15 days of the start of the
registration process. Draw statechart diagram showing the states of registration

Juhi patel UTU Page 14 of 18


OOSE BCA SEM IV

Storing persistent data in database

» The persistent objects stay alive even after the program is no longer
longer in execution.
» Thus it is need to store objects permanently in the secondary memory.
DBMS is a software system that can manage large amount of data in an efficient
manner

DBMS offers features

1. Efficient storage of data


Data is stored in an external storage devices.
2. Data independence
Application programs are kept as much independent as possible
from internal details of management and storage of data.
3. Integrity and security
Verification checks can be enforced before insertion of data.
Portion
rtion of database must be visible to given users
4.. Concurrency control and recovery
DBMS allows multiple users to work simultaneously
Provide facility of recovering database
5. Easy query
DBMS allows user to access data in required manner easily.

Mapping entity classes to database tables

» In relational model, data is stored in the form of a table.


» An entity class must be represented in the form of a table in database.

Juhi patel UTU Page 15 of 18


OOSE BCA SEM IV

Inheritance in tables

» If the entity class are having generalization relationships, following ways to convert then into
tables
The base class and derived classes are converted into tables.
• derived class consists of reference to the primary key of the base table.
• primary key of tables of derived class are same as of tables of base class.
The inherited attributes are copied to all the tables of derived class.

Juhi patel UTU Page 16 of 18


OOSE BCA SEM IV

Implementing the classes


» Implementation part can begin using specified programming language.
» The developed source code should follow
Good programming practice
Coding standards specific to the programming languages being used.

Juhi patel UTU Page 17 of 18


OOSE BCA SEM IV

Good programming practice


» Use of meaningful variable names
» Use of documentation
» Use global data rarely
» Use consistent formatting
» Use of error messages
» Use of if statement

Coding standards

» The coding standards specify the restrictions on the programming language.


» Following coding standard are provided in Java language.
o Developers write code to catch all the possible exception
o Use of reusable components include Java standard library classes
o Files are divided into different packages
o Documentation ( include implementation comments)

Refactoring

» Refactoring is the process of changing a computer program's source code without


modifying its external functional behavior
» Advantages of Refactoring
o improves the internal structure of program without changing the functionality of
the software.
o Improved understandability and readability
o Decrease software complexity of source code
o Enhance maintainability
o Ease of enhancement
o Ease of adding new features

Reusability

» The components of the software should be easily reusable in some other software.
» Aim of implementation should be
To build high-quality and maintainable components that can be reused.

Juhi patel UTU Page 18 of 18

You might also like