Sholpan Jomartova

Fundamentals of UML. Educational manual


Скачать книгу

is not a participant, who sent it, because it comes from an unknown source. It is called the search message (message found).

      Another approach can be seen in Figure 11. The main objective remains the same, but the way the interaction between the participants to solve it completely different. Order asks each order line on his own price (Prіce). The very order line transmits the calculation on – the object product (Product); note how the transfer of the parameter is shown. Likewise for the calculation order discount object invokes a method for the customer (Customer). As for the task the customer requires information from the object of the order, he does recall against an order to obtain the data.

      Figure 10. The sequence diagram of centralized management

      First, these two charts it is necessary to pay attention to how clearly the sequence diagram shows the differences in the interaction of the participants. This demonstrates the power of interaction diagrams. They are not very good are the details of algorithms, such as loops or conditional behavior, but make absolutely clear calls between the parties and give really clear picture of what kind of processing is performed specific participants.

      Second, the difference is clearly visible in the style of interaction between the two. Figure 10 is a centralized control (control centralіzed) when one of the participants largely performs all of the processing, and others provide information. Figure 14 shows a distributed control (dіstrіbuted control), in which the processing is distributed among many participants, each of which carries a small portion of the algorithm.

      Both styles have advantages and disadvantages. Most developers, especially beginners in object-oriented programming, the most commonly used centralized management. In many cases, it's easier, because all processing is concentrated in one place; In contrast, in the case of distributed control when trying to understand the program creates a feeling of chasing objects.

      Despite this, the more experienced analysts prefer distributed control. One of the main objectives of good design is to localize change. The data and program code to access these data, often change together. Therefore, data placement and access them programs in one place – thefirst rule of object-oriented design.

      In addition, distributed control enables to create more opportunities for the application of polymorphism than in the case of conditional logic. If the algorithms determine the prices differ for different types of products, distributed control mechanism allows the use subclasses of product (Product) for the treatment of these options.

      Figure 11. The sequence diagram for distributed control

      In general, object oriented style is designed to work with a large number of small objects with many small methods, which gives ample opportunity to redefine and change. This style of confusing people who use long procedure; really is the heart of this change of paradigm shift (paradіgm shіft) with object orientation. To teach this difficult. It seems that the only way to truly understand it is to use a distributed control when working in object-oriented environment.

      The sequence diagrams to create and delete participants apply some additional notation (Figure 12). In the case of a party need to draw an arrow Communication addressed to the rectangle of the participant. If you use the constructor, the name of the message is optional, but it may be marked with the word «new». If a participant carries something immediately after creation, for example, the request command, it is necessary to start immediately after the activation of the rectangle party.

      Remote participants designated a large cross (X). Arrow posts, running in the X, it means that one participant explicitly removes another; X at the end of the life line indicates that the party removes himself.

      If the system runs a garbage collector, objects are then removed manually nevertheless be using X indicate that the object is no longer needed and is ready for removal. This should be the case and closing operations, indicating that the object is no longer used.

      Loops and conditions

      The general problem is to sequence diagrams how to display loops and conditional structure. First of all it is necessary to understand that sequence diagrams are not designed for this. Such control structures best show with the help of activity diagrams, or custom code. Sequence diagrams are used to visualize the process of interaction of objects, not as a means of modeling the control algorithm.

      There are additional designations. And for loops, and conditions for interaction use frames (frames іnteractіon), is a means of marking interaction diagrams. Figure 13 shows a simple algorithm based on the following pseudocode.

      fоrеach (lіnеіtеm)

      іf (prоduct.valuе> $10K)

      carеful.dіspatch

      еlsе

      rеgular.dіspatch

      еnd іf

      еnd fоr

      іf (nееdsCоnfіrmatіоn) mеssеngеr. cоnfіrm

      The frame consists mainly of a region sequence chart divided into several fragments. Each frame has an operator, and each moiety may be protected. Table 3 lists common operators for interaction frames. To display the cycle operator is applied to a single loop fragment, and the body is placed in the protection of the iteration. For conditional logic you can use the alt and put the condition in each piece. It will be executed only one fragment, the protection of which is true. For the sole operator of the field, there opt.

      Table 3

      Common operators for interaction frames

      Figure 12. Creating and removing members

       Synchronous and asynchronous calls

      In UML version 2 shaded arrows show the synchronous message and simple arrows indicate asynchronous message.

      If the caller sends a synchronous message (sunchronous message), then he should wait until the message processing is completed, for example, when you call the subroutine. If the caller sends an asynchronous message (asunchronous message), then he can continue to work and not have to wait for a response. Asynchronous calls can be found in multi-threaded applications and middleware, message-oriented. Asynchronous improves the response time and reduces the number of connections, but more difficult to debug.

      The difference is subtle image of arrows; they are difficult to distinguish. Therefore, reading the sequence diagram to make assumptions about the synchronicity of mind arrows However, make sure that the author deliberately drew them different.

      Figure 13. Frames interaction

       When used sequence diagrams

      Sequence diagrams should be used when you want to look at the behaviorof several objects within a single use case. Sequence diagrams are good for representing the interaction of objects, but not very suitable for accurate determination of behavior.

      If you want to look at the behavior of a single object in several precedents, it is best to use a state diagram. If it is necessary to study the behavior of several objects in a few precedents or streams suitable activity diagram.

      1. Sequence diagram is an example of:

      a) collaboration diagram;

      b) interaction diagram;

      c) class diagram;

      d) use case diagram.

      2. Sequence diagrams depict all the objects that implement functionality of precedent:

      a) true;

      b) false.

      3. Sequence diagrams give a good idea of how to implement a function:

      a) true;

      b) false.

      4.