8
 A TERM PA PER ON Use of Interaction Diagram for Object Oriented Systems  Subject: Object Oriented Tecni!ues "ace#or of Tecno#ogy In $om%uter Science & Engineering Session: '()*+'(), Submitted to: Submitted by: Mr- .risna /iri Anurag Arora $S+,)  )')'')(('0  S1RI RAMS2AROOP MEMORIA3 /ROUP O4 PRO4ESSIONA3 $O33E/ES5 3U$.NO2 Affi#iated to /-"- TE$1NI$A3 UNI6ERSIT75 3U$.NO2

Interaction

Embed Size (px)

DESCRIPTION

ATERM PAPER ON Use of Interaction Diagram for Object Oriented Systems

Citation preview

ATERM PAPER ON Use of Interaction Diagram for Object Oriented Systems Subject: Object Oriented Techniques Bachelor of Technology In Computer Science & Engineering Session: 2014-2015 Submitted to: Submitted by: Mr. Krishna Giri Anurag Arora CS-51 1212210027

SHRI RAMSWAROOP MEMORIAL GROUP OF PROFESSIONAL COLLEGES, LUCKNOW Affiliated to G.B. TECHNICAL UNIVERSITY, LUCKNOW

Introduction:

Interaction diagrams, a subset of behaviour diagrams, emphasize the flow of control and data among the things in the system being modelled. For example, thesequence diagram which shows how objects communicate with each other in terms of a sequence of messages.There are three kinds of diagrams in UML that depict dynamic models. State diagrams describe how a system responds to events in a manner that is dependent upon its state. Systems that have a fixed number of states, and that respond to a fixed set of events are called finite state machines (FSM). UML has a rich set of notational tools for describing finite state machines. Well be investigating them in another column.The other two kinds of dynamic diagram fall into a category called Interaction diagrams. They both describe the flow of messages between objects. However, sequence diagrams focus on the order in which the messages are sent. They are very useful for describing the procedural flow through many objects. They are also quite useful for finding race conditions in concurrent systems. Collaboration diagram, on the other hand, focus upon the relationships between the objects. They are very useful for visualizing the way several objects collaborate to get a job done and for comparing a dynamic model with a static model.Collaboration and sequence diagrams describe the same information, and can be transformed into one another without difficulty. The choice between the two depends upon what the designer wants to make visually apparent.

Interaction Diagrams:

Interaction diagrams are models that describe how a group of objects collaborate to realize some behaviour. Typically, each interaction diagram realizes the behaviour of a single use case. An interaction diagram shows a number of example objects and the messages that are passed between the objects within the use case.There are two types of interaction diagrams: sequence diagrams and collaboration diagrams. These two diagrams are equivalent in the sense that any one diagram can be derived automatically from the other. However, they are both useful. These two actually portray different perspectives of behaviour of the system and different types of inferences can be drawn from them. The interaction diagrams can be considered as a major tool in the design methodology.Kinds of interaction diagram: Collaboration Diagram: A UML interaction diagram showing a set of objects connected bycommunications links. Sequence diagrams: A UML interaction diagram showing the sequence of messages exchanged by the set of objects and optionally an actor. Actors and objects are on one axis, and time is on the other.Purpose of Interaction Diagram:

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.

Drawing Interaction 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 be 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 modelling 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 forSpecialOrderobject and the same can be used in case ofNormalOrderobject. 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 issendOrder ()which is a method ofOrderobject. The next call isconfirm ()which is a method ofSpecialOrderobject and the last call isDispatch ()which is a method of SpecialOrderobject. 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 Collaboration Diagram:

The second interaction diagram is collaboration diagram. It shows the object organization as shown below. Here in collaboration diagram the method call sequence is indicated by some numbering technique as shown below. The number indicates how the methods are called one after another. We have taken the same order management system to describe the collaboration diagram.The method calls are similar to that of a sequence diagram. But the difference is that the sequence diagram does not describe the object organization whereas the collaboration diagram shows the object organization.Now to choose between these two diagrams the main emphasis is given on the type of requirement. If the time sequence is important then sequence diagram is used and if organization is required then collaboration diagram is used.

Comparing and Contrasting: (Collaboration and Sequence)

Both diagrams show the same information Objects/classes Messages Sequence Conditional Repetition Messages to self

Collaboration diagrams emphasize who-is-talking-to-who But the time-ordering of the messages gets obscured

Sequence diagrams emphasize time-ordering But the who-is-talking-to-who gets obscured Use the diagram that you are most comfortable with A good CASE tool really ought to be able to generate one given the other

Applications of Interaction Diagrams:

We have already discussed that interaction diagrams are used to describe dynamic nature of a system. Now we will look into the practical scenarios where these diagrams are used. To understand the practical application we need to understand the basic nature of sequence and collaboration diagram.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.

Conclusion:

From the nameInteractionit is clear that the diagram is used to describe some type of interactions among the different elements in the model. So this interaction is a part of dynamic behaviour of the system.This interactive behaviour is represented in UML by two diagrams known asSequence diagram andCollaboration 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.

References:

Steve Heath, Embedded System Design: Real World Design, Butter-worth Heinemann, Newton, Mass., USA, May 2002. Hatley D. and Pirbhai I., Strategies for Real-Time System Specification, Dorset House, New York, 1987. Sommerville, Software Engineering, Addison Wesley, Reading, MA, USA, 2000.