Ooad Unit3 Notes PDF
Ooad Unit3 Notes PDF
interfaces are actually used and what messages/actions are expected at different times gives each
team a consistent and robust implementation plan. You can also document how special cases
should be handled across the entire system.
The very act of creating the sequence diagrams and making them work with your architecture is
valuable because it forces you to think about details such as interfaces, states, message order,
assignment of responsibilities, timers/timeouts and special/error cases ahead of time.
2. Collaboration tool. Sequence diagrams are valuable collaboration tools during design
meetings because they allow you to discuss the design in concrete terms. You can see the
interactions between entities, various proposed state transitions and alternate courses/special
cases on paper as you discuss the design.
In our experience, having a concrete design proposal during design meetings greatly enhances
the productivity of these meetings even if the proposed design has problems. You can narrow
down the problems and then make corrections to solve them. The proposal serves as a concrete
starting point for the discussion and as a place to capture proposed changes.
Sequence diagram editor makes it so easy to edit your sequence diagrams that you could even
make the corrections in real time during the meeting and instantly see the result of the changes as
you make them.
3. Documentation. Sequence diagrams can be used to document the dynamic view of the system
design at various levels of abstraction, which is often difficult to extract from static diagrams or
even the complete source code. The diagrams can abstract much of the implementation detail and
provide a high level view of system behavior.
Below is a sequence diagram for making a hotel reservation. The object initiating the sequence
of messages is a Reservation window.
The diagram has a clarifying note, which is text inside a dog-eared rectangle. Notes can be put
into any kind of UML diagram.
Logical Architecture
A package diagram is a UML diagram composed only of packages and the dependencies
between them. A package is a UML construct that enables you to organize model elements, such
as use cases or classes, into groups. Packages are depicted as file fo lders and can be applied on
any UML diagram. Create a package diagram to:
Depict a high- level overview of your requirements (overviewing a collection of UML
Use Case diagrams)
Depict a high- level overview of your architecture/design (overviewing a collection of
UML Class diagrams).
To logically modularize a complex diagram.
To organize Java source code.
There are guidelines for:
1. Class Package Diagrams
2. Use Case Package Diagrams
3. Packages
3. Packages
The advice presented in this section is applicable to the application of packages on any UML
diagram, not just package diagrams.
1. Give Packages Simple, Descriptive Names
2. Apply Packages to Simplify Diagrams
3. Packages Should be Cohesive
4. Indicate Architectural Layers With Stereotypes on Packages
5. Avoid Cyclic Dependencies Between Packages
6. Package Dependencies Should Reflect Internal Relationships
Class diagrams also display relationships such as containment, inheritance, associations and
others.2 Below is an example of an associative relationship:
The association relationship is the most common relationship in a class diagram. The association
shows the relationship between instances of classes. For example, the class Order is associated
with the class Customer. The multiplicity of the association denotes the number of objects that
can participate in then relationship.1 For example, an Order object can be associated to only one
customer, but a customer can be associated to many orders.
Another common relationship in class diagrams is a generalization. A generalization is used
when two classes are similar, but have some differences. Look at the generalization below:
In this example the classes Corporate Customer and Personal Customer have some similarities
such as name and address, but each class has some of its own attributes and operations. The
class Customer is a general form of both the Corporate Customer and Personal Customer
classes.1 This allows the designers to just use the Customer class for modules and do not require
in-depth representation of each type of customer.
When to Use: Class Diagrams
Class diagrams are used in nearly all Object Oriented software designs. Use them to describe the
Classes of the system and their relationships to each other.
How to Draw: Class Diagrams
Class diagrams are some of the most difficult UML diagrams to draw. To draw detailed and
useful diagrams a person would have to study UML and Object Oriented principles for a long
time. Therefore, this page will give a very high level overview of the process. To find list of
where to find more information see the Resources page.
Before drawing a class diagram consider the three different perspectives of the syste m the
diagram will present; conceptual, specification, and implementation. Try not to focus on one
perspective and try see how they all work together.
When designing classes consider what attributes and operations it will have. Then try to
determine how instances of the classes will interact with each other. These are the very first steps
of many in developing a class diagram. However, using just these basic techniques one can
develop a complete view of the software system.
This interactive behaviour is represented in UML by two diagrams known as Sequence diagram
and Collaboration diagram. The basic purposes of both the diagrams are similar.
Sequence diagram emphasizes on time sequence of messages and collaboration diagram
emphasizes on the structural organization of the objects that send and receive messages.
Purpose:
The purposes of interaction diagrams are to visualize the interactive behaviour of the system.
Now visualizing interaction is a difficult task. So the solution is to use different types of models
to capture the different aspects of the interaction.
That is why sequence and collaboration diagrams are used to capture dynamic nature but from a
different angle.
So the purposes of interaction diagram can be describes as:
To capture dynamic behaviour of a system.
To describe the message flow in the system.
To describe structural organization of the objects.
To describe interaction among objects.
How to draw Component Diagram?
As we have already discussed that the purpose of interaction diagrams are to capture the dynamic
aspect of a system. So to capture the dynamic aspect we need to understand what a dynamic
aspect is and how it is visualized. Dynamic aspect can be defined as the snap shot of the running
system at a particular moment.
We have two types of interaction diagrams in UML. One is sequence diagram and the other is a
collaboration diagram. The sequence diagram captures the time sequence of message flow from
one object to another and the collaboration diagram describes the organization of objects in a
system taking part in the message flow.
So the following things are to identified clearly before drawing the interaction diagram:
Objects taking part in the interaction.
Message flows among the objects.
The sequence in which the messages are flowing.
Object organization.
Following are two interaction diagrams modeling order management system. The first diagram is
a sequence diagram and the second is a collaboration diagram.
The Sequence Diagram:
The sequence diagram is having four objects (Customer, Order, SpecialOrder and NormalOrder).
The following diagram has shown the message sequence for SpecialOrder object and the same
can be used in case of NormalOrder object. Now it is important to understand the time sequence
of message flows. The message flow is nothing but a method call of an object.
The first call is sendOrder () which is a method of Order object. The next call is confirm ()
which is a method of SpecialOrder object and the last call is Dispatch () which is a method of
SpecialOrder object. So here the diagram is mainly describing the method calls from one object
to another and this is also the actual scenario when the system is running.
The main purposes of both the diagrams are similar as they are used to capture the dynamic
behaviour of a system. But the specific purposes are more important to clarify and understood.
Sequence diagrams are used to capture the order of messages flowing from one object to another.
And the collaboration diagrams are used to describe the structural organizations of the objects
taking part in the interaction. A single diagram is not sufficient to describe the dynamic aspect of
an entire system so a set of diagrams are used to capture is as a whole.
The interaction diagrams are used when we want to understand the message flow and the
structural organization. Now message flow means the sequence of control flow from one object
to another and structural organization means the visual organization of the elements in a system.
In a brief the following are the usages of interaction diagrams:
To model flow of control by time sequence.
To model flow of control by structural organizations.
For forward engineering.
For reverse engineering.