Sei sulla pagina 1di 38

LAB MANUAL

OBJECT ORIENTED ANALYSIS & DESIGN


WITH UML

Manual By:
Ms Sarika Arora
Assistant Professor,IT Dept
KCL-IMT,Jalandhar

OOAD with UML

Ms. Sarika Arora,KCL-IMT,Jalandhar

INTRODUCTION:
The Unified Modeling Language has been designed to support Object Orientation, and well be
introducing Object Oriented concepts throughout this manual. OO tries to lessen the impact of
this problem by simply combining related data and functions into the same module.
The heart of object-oriented problem solving is the construction of a model. The model abstracts
the essential details of the underlying problem from its usually complicated real world. In late
1960s people were concentrating on Procedure Oriented Languages such as COBOL,
FORTRAN, PASCALetc. Later on they preferred Object Oriented Languages. In the
middle of 1970-80 three Scientists named as BOOCH, RUMBAUGH and JACOBSON found a
new language named as Unified Modeling Language. It encompasses the Designing of the
System/Program.
Object Oriented Development (OOD) has been advertised as the next great advancement in
software engineering. It promises to reduce development time and resources required to maintain
existing applications, increase code reuse, and provide a competitive advantage to organizations
that use it.
Benefits of OOD

Faster Development: OOD has long been touted as leading to faster development. Many
of the claims of potentially reduced development time are correct in principle, if a bit
overstated.
Reuse of Previous work: This is the benefit cited most commonly in literature,
particularly in business periodicals. OOD produces software modules that can be plugged
into one another, which allows creation of new programs. However, such reuse does not
come easily. It takes planning and investment.
Increased Quality: Increases in quality are largely a by-product of this program reuse. If
90% of a new application consists of proven, existing components, then only the
remaining 10% of the code has to be tested from scratch. That observation implies an
order-of-magnitude reduction in defects.
Modular Architecture: Object-oriented systems have a natural structure for modular
design: objects, subsystems, framework, and so on. Thus, OOD systems are easier to
modify. OOD systems can be altered in fundamental ways without ever breaking up since
changes are neatly encapsulated. However, nothing in OOD guarantees or requires that
the code produced will be modular. The same level of care in design and implementation
is required to produce a modular structure in OOD, as it is for any form of software
development.
Client/Server Applications: Client/server applications involve transmission of messages
back and forth over a network, and the object-message paradigm of OOD meshes well
with the physical and conceptual architecture of client/server applications.
Better Mapping to the Problem Domain: When the project maps to the real world.
Whether objects represent customers, machinery, banks, sensors or pieces of paper, they
can provide a clean, self-contained implication which fits naturally into human thought
processes.

OOAD with UML

Ms. Sarika Arora,KCL-IMT,Jalandhar

UML and its Importance


UML is a language. It is not simply a notation for drawing diagrams, but a complete language
for capturing knowledge (semantics) about a subject and expressing knowledge (syntax)
regarding the subject for the purpose of communication.
Applies to modeling and systems. Modeling involves a focus on understanding a subject
(system) and capturing and being able to communicate in this knowledge.
It is the result of unifying the information systems and technology industrys best engineering
practices (principals, techniques, methods and tools).
used for both database and software modeling.

For Example: Architects design buildings. Builders use the designs to create buildings. The more
complicated the building, the more critical the communication between architect and builder.
Blueprints are the standard graphical language that both architects and builders must learn as part
of their trade.
Writing software is not unlike constructing a building. The more complicated the underlying
system, the more critical the communication among everyone involved in creating and deploying
the software. In the past decade, the UML has emerged as the software blueprint language for
analysts, designers, and programmers alike. It is now part of the software trade. The UML gives
everyone from business analyst to designer to programmer a common vocabulary to talk about
software design.
The UML is applicable to object-oriented problem solving. Anyone interested in learning UML
must be familiar with the underlying tenet of object-oriented problem solving -- it all begins with
the construction of a model. A model is an abstraction of the underlying problem

Overview of the UML


The UML is a language for
a) visualizing
b) specifying
c) constructing
d) documenting

OOAD with UML

Ms. Sarika Arora,KCL-IMT,Jalandhar

a) Visual modeling (visualizing)

A picture is worth a thousand words!


- Uses standard graphical notations
- Semi-formal
- Captures Business Process from enterprise information systems to distributed Web-based
applications and even to hard real time embedded systems

OOAD with UML

Ms. Sarika Arora,KCL-IMT,Jalandhar

b) Specifying

building models that are: Precise, Unambiguous, and Complete


UML symbols are based on well-defined syntax and semantics.
UML addresses the specification of all important analysis, design, and implementation
decisions.

c) Constructing

Models are related to OO programming languages.


Round-trip engineering requires tool and human intervention to avoid information loss
Forward engineering direct mapping of a UML model into code.
Reverse engineering reconstruction of a UML model from an implementation.

d) Documenting

Architecture, Requirements, Tests, Activities (Project planning, Release management)


Conceptual Model of the UML
To understand the UML, you need to form a conceptual model of the language, and this requires
learning three major elements.
Elements:
1. Basic building blocks
2. Rules
3. Common Mechanisms

Basic Building Blocks of the UML


The vocabulary of the UML encompasses three kinds of building blocks:
Things Relationships Diagrams

*Things in the UML

There are four kinds of things in the UML:


1. Structural nouns of UML models.
2. Behavioral dynamic (verbal) parts of UML models.
3. Grouping organizational parts of UML models.
4. Annotational explanatory parts of UML models.

OOAD with UML

Ms. Sarika Arora,KCL-IMT,Jalandhar

1. Structural Things
These are the Nouns and Static parts of the model.
These are representing conceptual or physical elements.
There are seven kinds of structural things:
1. Class
2. Interface
3. Collaboration
4. Use Case
5. Active Class
6. Component
7. Node

a) Class
It is a description of set of objects that share the same attributes, operations methods,
relationships and semantics.

b) Interface
A collection of operations that specify a service (for a resource or an action) of a class or
component. It describes the externally visible behavior of that element.

OOAD with UML

Ms. Sarika Arora,KCL-IMT,Jalandhar

c) Collaboration
Define an interaction among two or more classes. Define a society of roles and other
elements. Provide cooperative behavior. Capture structural and behavioral dimensions.

d) Use Case
A sequence of actions that produce an observable result for a specific actor.
A set of scenarios tied together by a common user goal.
Provides a structure for behavioral things.
Realized through a collaboration (usually realized by a set of actors and the system to be built).

e) Active Class
Special class whose objects own one or more processes or threads.
Can initiate control activity.

OOAD with UML

Ms. Sarika Arora,KCL-IMT,Jalandhar

f) Component

Replaceable part of a system.


Components can be packaged logically.
Conforms to a set of interfaces.
Provides the realization of an interface.
Represents a physical module of code

g) Node

Element that exists at run time.


Represents a computational resource.
Generally has memory and processing power.

OOAD with UML

Ms. Sarika Arora,KCL-IMT,Jalandhar

2. Behavioral Things
These are Verbs of UML models.
These are Dynamic parts of UML models: behavior over time and space
Usually connected to structural things in UML.

There are two kinds of Behavioral Things:

a) Interaction

Is a behavior of a set of objects comprising of a set of messages exchanges within a particular


context to accomplish a specific purpose.

b) State Machine

Is a behavior that specifies the sequences of states an object or an interaction goes through
during its lifetime in response to events, together with its responses to those events.

OOAD with UML

Ms. Sarika Arora,KCL-IMT,Jalandhar

3. Grouping Things
These are the organizational parts of the UML models.
There is only one primary kind of group thing:

#Packages
- General purpose mechanism for organizing elements into groups.
- Purely conceptual; only exists at development time.
- Contains behavioral and structural things.
- Can be nested.
- Variations of packages are: Frameworks, models, & subsystems.

4. Annotational Things
These are Explanatory parts of UML models
These are the Comments regarding other UML elements (usually called adornments in UML)
There is only one primary kind of annotational thing:

1. Note
A note is simply a symbol for rendering constraints and comments attached to an element or
collection of elements.
Is a best expressed in informal or formal text.

OOAD with UML

Ms. Sarika Arora,KCL-IMT,Jalandhar

*Relationships
There are four kinds of relationships:
1. Dependency
2. Association
3. Generalization
4. Realization
These relationships tie things together.
It is a semantic connection among elements.
These relationships are the basic relational building blocks of the UML.

1. Dependency
Is a semantic relationship between two things in which a change to one thing (the independent
thing) may affect the semantics of the other thing (the dependent thing).

2. Association
Is a structural relationship that describes a set of links, a link being a connection among objects.

Aggregation
Is a special kind of association. It represents a structural
relationship between the whole and its parts.
Represented by black diamond.

3. Generalization
Is a specialization/generalization relationship in which objects of the specialized element (the
child) are more specific than the objects of the generalized element.

OOAD with UML

Ms. Sarika Arora,KCL-IMT,Jalandhar

4. Realization
a semantic relationship between two elements, wherein one element guarantees to carry out what
is expected by the other element.

OOAD with UML

Ms. Sarika Arora,KCL-IMT,Jalandhar

*Diagrams

A diagram is the graphical presentation of a set of elements.


Represented by a connected graph: Vertices are things; Arcs are behaviors.

Basically we will explain UMLs below diagrams:


Class Diagram;
Object Diagram
Use case Diagram
Sequence Diagram;
Collaboration Diagram
State chart Diagram
Activity Diagram
Component Diagram
Deployment Diagram

OOAD with UML

Ms. Sarika Arora,KCL-IMT,Jalandhar

1. Class Diagram
Class Diagrams describe the static structure of a system, or how it is structured rather than
how it behaves.
A class diagram shows the existence of classes and their relationships in the logical view of a
system
These diagrams contain the following elements.
Classes and their structure and behavior
Association, aggregation, dependency, and inheritance relationships
Multiplicity and navigation indicators
Role names
These diagrams are the most common diagrams found in O-O modeling systems.

Multiplicities Meaning
0..1

zero or one instance. The notation n . . m indicates n to m instances.

0..* or *

no limit on the number of instances (including none).

exactly one instance

1..*

at least one instance

OOAD with UML

Ms. Sarika Arora,KCL-IMT,Jalandhar

Example:

2. Object Diagrams
Shows a set of objects and their relationships.
A static snapshot of instances.
Object Diagrams describe the static structure of a system at a particular time. Whereas a class
model describes all possible situations, an object model describes a particular situation.
Object diagrams contain the following elements:
Objects which represent particular entities. These are instances of classes.
Links which represent particular relationships between objects. These are instances of
associations.

OOAD with UML

Ms. Sarika Arora,KCL-IMT,Jalandhar

3. Use case diagrams


Use Case Diagrams describe the functionality of a system and users of the system.
These diagrams contain the following elements:
Actors: which represent users of a system, including human users and other systems.
Use Cases: which represent functionality or services provided by a system to users.

Use case diagrams are used during requirements elicitation and analysis as a graphical
means of representing the functional requirements of the system. A use case diagram is a visual
representation of the relationships between actors and use
cases together that documents the systems intended behavior.Use cases are
developed during requirements elicitation and are further refined and corrected as they
are reviewed during analysis. Use cases are also very helpful for
writing acceptance test cases.
In UML, a use case is represented as an ellipse

An actor represents whoever or whatever (person, machine, or other) interacts with the
system. The actor is not part of the system itself and represents anyone or anything that
must interact with the system to:
Input information to the system;
Receive information from the system; or
Both input information to and receive information from the system.
Arrows and lines are drawn between actors and use cases and between use cases to show
their relationships. The default relationship between an actor and a use case is the
communicates relationship,denoted by a line. When a line or an arrow is drawn on a diagram
and there is no label on the arrow, it is, by default, a communicates relationship.

OOAD with UML

Ms. Sarika Arora,KCL-IMT,Jalandhar

OOAD with UML

Ms. Sarika Arora,KCL-IMT,Jalandhar

4. Sequence diagrams
Sequence Diagrams describe interactions among classes. These interactions are
modeled as exchanges of messages.
These diagrams focus on classes and the messages they exchange to accomplish
Some desired behavior.
Sequence diagrams are a type of interaction diagrams.
Sequence diagrams contain the following elements:
Class roles: which represent roles that objects may play within the interaction.
Lifelines: which represent the existence of an object over a period of time.
Activations: which represent the time during which an object is performing an operation.
Messages: which represent communication between objects.

5. Collaboration Diagram
Collaboration Diagrams describe interactions among classes and associations.
These interactions are modeled as exchanges of messages between classes
Through their associations. Collaboration diagrams are a type of interaction
Diagram.
Collaboration diagrams contain the following elements.
Cass roles: which represent roles that objects may play within the interaction.
Association roles: which represent roles that links may play within the interaction.
Message flows: which represent messages sent between objects via links. Links transport or
implement the delivery of the message.

OOAD with UML

Ms. Sarika Arora,KCL-IMT,Jalandhar

6. Statechart Diagrams
State chart (or state) diagrams describe the states and responses of a class. Statechart
Diagrams describe the behavior of a class in response to external stimuli.
These diagrams contain the following elements:
States: which represent the situations during the life of an object in which it satisfies some
condition, performs some activity, or waits for some occurrence.
Transitions: which represent relationships between the different states of an object.

7. Activity Diagrams
Activity diagrams describe the activities of a class. These diagrams are similar to
Statechart diagrams and use similar conventions, but activity diagrams describe the
behavior of a class in response to internal processing rather than external events as in
Statechart diagram.
Swimlanes: which represent responsibilities of one or more objects for actions within an overall
activity; that is, they divide the activity states into groups and assign these groups to object that
must perform the activities.
Action States: which represent atomic, or noninterruptible, actions of entities or steps in the
execution of an algorithm.
Action flows: which represent relationships between the different action states of an entity.
Object flows: which represent the utilization of objects by action states and the influence of
action states on objects.

OOAD with UML

Ms. Sarika Arora,KCL-IMT,Jalandhar

8. Component Diagram
Component diagrams describe the organizations and dependencies among software
Implementation components. These diagrams contain components, which represent
Distributable physical units, including source code, object code, and executable code.
These are static implementation view of a system.

OOAD with UML

Ms. Sarika Arora,KCL-IMT,Jalandhar

9. Deployment Diagrams
Deployment diagrams describe the configuration of run-time processing resource
elements and the mapping of software implementation components onto them. These
Diagrams contain components and nodes, which represent processing or computational
resources, including computers, printers, etc.

OOAD with UML

Ms. Sarika Arora,KCL-IMT,Jalandhar

Draw the diagrams of following CASES using UML:


Sr. No
1

Case Code
U1

U2

3
4

CL1
CL2

O1

O2

S1

S2

A1

10

A2

11

ST1

12

ST2

13

COL1

14

COL2

15

COM1

16

COM2

OOAD with UML

Case Title
Draw Use Case Diagram of Clerk and
employee interaction in a system
Draw Use Case Diagram of reservation system
i.e either may be train or bus
Draw Class Diagram of Seminar System
Draw Class Diagram of Order Management
System
Draw Object Diagram of Order Management
System by owner of the company.
Draw Object Diagram of Customer Order
System
Draw Sequence Diagram of Room booking
system in a hotel
Draw Sequence Diagram of Order Management
System in a company.
Draw Activity Diagram of ATM System of any
bank
Draw Activity Diagram of Order Management
System
Draw state chart Diagram of Money withdrawal
System from ATM
Draw state chart Diagram of Loan Approval
System by a bank
Draw Collaboration Diagram of Bus Ticket
purchasing System
Draw Collaboration Diagram of
Order
management System
Draw Component Diagram of Customer Care
System
Draw Component Diagram of Online Shopping
System

Ms. Sarika Arora,KCL-IMT,Jalandhar

Diagrams of above all cases are:


1

U1

OOAD with UML

Draw Use Case Diagram of Clerk and


employee interaction in a system

Ms. Sarika Arora,KCL-IMT,Jalandhar

U2

OOAD with UML

Draw Use Case Diagram of reservation system


i.e either may be train or bus

Ms. Sarika Arora,KCL-IMT,Jalandhar

CL1

OOAD with UML

Draw Class Diagram of Seminar System

Ms. Sarika Arora,KCL-IMT,Jalandhar

CL2

OOAD with UML

Draw Class Diagram of Order Management


System

Ms. Sarika Arora,KCL-IMT,Jalandhar

O1

OOAD with UML

Draw Object Diagram of Order Management


System by owner of the company.

Ms. Sarika Arora,KCL-IMT,Jalandhar

O2

OOAD with UML

Draw Object Diagram of Customer Order


System

Ms. Sarika Arora,KCL-IMT,Jalandhar

S1

OOAD with UML

Draw Sequence Diagram of Room booking


system in a hotel

Ms. Sarika Arora,KCL-IMT,Jalandhar

S2

OOAD with UML

Draw Sequence Diagram of Order Management


System in a company.

Ms. Sarika Arora,KCL-IMT,Jalandhar

A1

OOAD with UML

Draw Activity Diagram of ATM System of any


bank

Ms. Sarika Arora,KCL-IMT,Jalandhar

10

A2

OOAD with UML

Draw Activity Diagram of Order Management


System

Ms. Sarika Arora,KCL-IMT,Jalandhar

11

ST1

OOAD with UML

Draw state chart Diagram of Money withdrawal


System from ATM

Ms. Sarika Arora,KCL-IMT,Jalandhar

12

ST2

OOAD with UML

Draw state chart Diagram of Loan Approval


System by a bank

Ms. Sarika Arora,KCL-IMT,Jalandhar

13

COL1

OOAD with UML

Draw Collaboration Diagram of Bus Ticket


purchasing System

Ms. Sarika Arora,KCL-IMT,Jalandhar

14

COL2

OOAD with UML

Draw Collaboration Diagram of


management System

Order

Ms. Sarika Arora,KCL-IMT,Jalandhar

15

COM1

OOAD with UML

Draw Component Diagram of Customer Care


System

Ms. Sarika Arora,KCL-IMT,Jalandhar

16

COM2

OOAD with UML

Draw Component Diagram of Online Shopping


System

Ms. Sarika Arora,KCL-IMT,Jalandhar

Potrebbero piacerti anche