Presentation is loading. Please wait.

Presentation is loading. Please wait.

ITEC1301 Object-Oriented Systems Construction Lecture Notes #4 1.

Similar presentations


Presentation on theme: "ITEC1301 Object-Oriented Systems Construction Lecture Notes #4 1."— Presentation transcript:

1 ITEC1301 Object-Oriented Systems Construction Lecture Notes #4 1

2 Instances 2  In the UML, you can represent instances, especially objects.  Instance and object are almost the same.  In general, an object is something that takes up space in the real or conceptual world, and you can do things to it.  Instances are commonly found in object diagrams.

3 Types and Names 3  The instance can be an named instance or an anonymous instance.  The type of actual instance must be a concrete classifier.  During development, you may have instances with no associated type.

4 Types and Names 4

5 Operation and State 5

6 Object Diagram 6  With the UML, an object diagram expresses the static part of an interaction.  An object diagram freezes a moment in time.

7 Object Diagram Example 7

8 Common Properties and Usages 8  Object diagrams commonly contain  Objects  Links  Object diagrams may contain notes and constraints.  Object diagrams let you model static data structures.  Object diagrams let you present one static snapshot of an system interaction.

9 More Example 9

10 Interactions 10  You use interactions to model the dynamic aspect of collaborations.  A collaboration represents societies of objects playing specific roles, all working together to carry some behavior.

11 Example 11

12 Interactions 12  Interactions introduces objects that work together to carry out some action.  Interactions also introduce messages that are dispatched from object to object.  You use interactions to model flow of control.  An interaction is similar to an object diagram. In addition, an interaction introduces a sequence of messages that may pass along the links.

13 Objects/Roles/Links/Connectors 13

14 Links and Connectors (2) 14  In general, a link is an instance of an association.  Wherever a class has an association, there may be a link between the instances of two classes.  Wherever, there is a link between two objects, one object may send a message to the other object.

15 Links and Connectors (3) 15  In most models, we are more interested in prototypical objects and links rather than individual objects and links.  A prototypical object is a role.  A prototypical link is a connector.  The multiplicity of roles and connectors are relative to their context.

16 Messages 16  A message is a communication among objects that conveys information with the expectation that activity will ensue.  When you pass a message, an action usually results on its receipt.  In the UML, you can model several kinds of messages.  Call  Return  Send  Create  Delete

17 Message Example 17

18 Messages (2) 18  The most common kind of messages is the call.  When you call an operation of an object, that operation must exist and visible in the target class.

19 Sending a Signal 19  Instead of sending a message, you may send a signal to the target object  A signal occurs asynchronously.  After sending a signal, the sending object continues its own execution. The target object independently decides what to do.

20 Sequencing 20  When an object passes a message to another object, the receiving object might in turn send a message to another object.  This forms a sequence.  A sequence usually causes a nested flow of control.

21 Sequencing (2) 21  On the other hand, a sequence may cause a flat flow of control.

22 Sequencing (3) 22  You may show the actual arguments and return value along with an operation or signal.  For example 1.3.2 : p := find(“Rachelle”)

23 Representation 23  You can visualize an interaction in two ways:  By emphasizing the time ordering of message. This diagram is called a sequence diagram.  By emphasizing the structural organization of roles that send and receive messages. This is called a communication diagram.  Both diagrams are kinds of interaction diagram.  model the dynamic aspects of a system is by building up storyboards of scenarios  Interaction diagrams commonly contain:  Roles or objects  Messages

24 Communication Diagrams 24

25 Sequence Diagrams 25  A sequence diagram emphasizes the time ordering of messages.

26 Sequence Diagram Example 26

27 Sequence Diagrams 27  Sequence diagrams have two features that distinguish them from communication diagrams.  First, there is the lifeline.  Second, there is the focus of control.  The main content in a sequence diagram is the messages.

28 28 Structured Control in Sequence Diagrams

29 Semantic Equivalence 29  Sequence diagrams and communication diagrams are semantically equivalent.  As a result, you can take a diagram in one form and convert it to the other without any loss of information.

30 Sequence Diagram Example 30

31 Communication Diagram Example 31

32 Common Uses 32  You typically use interaction diagrams in two ways.  To model flows of control by time ordering (sequence diagram).  To model flows of control by organization (communication diagram).

33 Modeling a Flow of Control 33  When you model an interaction, you essentially build a storyboard of the actions that take place among objects.  To model a flow of control,  Set the context for the interaction (a system, subsystem, class, operation).  Identify objects and their roles.  If drawing a communication diagram, identify links between objects.  In time order, specify messages from object to object. Distinguish different kind of messages, as necessary. Include parameters and return values.

34 Hints and Tips 34  A well-structured interaction  Is simple and should encompass only those objects that work together.  Has a clear context.  Is understandable and should be straightforward


Download ppt "ITEC1301 Object-Oriented Systems Construction Lecture Notes #4 1."

Similar presentations


Ads by Google