Fundamentals of UML. Educational manual. Sholpan Jomartova

Чтение книги онлайн.

Читать онлайн книгу Fundamentals of UML. Educational manual - Sholpan Jomartova страница 6

Fundamentals of UML. Educational manual - Sholpan Jomartova

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

oriented design should provide facilities with a rich behavior, so they should not just provide these other objects. If data is requested repeatedly by the means of access, this is a signal to the fact that such behavior should be transferred to the object that owns the data.

      These examples also confirm the fact that between the UML and the program is not mandatory compliance, but there the similarity. Conventions within the development team, will lead to better compliance.

      Regardless of how implemented feature – asa field or as a calculated value, it represents something that can always provide the object. Do not use the property for modeling transit relationships, such as the object passed as a parameter to a method call and is used only within the framework of this cooperation.

      Bidirectional associations

      Figure 6. Bidirectional associations

      Bidirectional Association – apair of related properties in opposite directions. Car class has a property owner: Person [1], and the class Person has a property cars: Car [*].

      Feedback between them means that if you follow both properties is expected to return back to the set containing the starting point.

      Alternatively, marking the association of the property, many people, especially if they have experience in data modeling, like to call the association with the help of verbs (Figure 10), the ratio can be used in a sentence. It is quite possible, and you can add an arrow to the association, to avoid uncertainty. Most developers prefer to use object property name, as it is more consistent functionality and operations.

      Some developers one way or another the name of each association. It is preferable to give the name of the association only when it improves understanding. Too often there are names such as «has» (a) or «the IS related» (associated with).

      In Figure 6, the bidirectional nature of the association is emphasized by the arrows at both ends of the association. Figure 7 arrows not; UML language in this form is used to denote a bidirectional association, or when the direction of the relationship is not shown.

      Figure 7. Using the verb in the name of the association

      Implementing a bidirectional associations in a programming language often presents some difficulty, since it is necessary to synchronize both properties. In C #, to implement bidirectional association can do the following:

      class Car…

      publіc Pеrsоn Оwnеr {

      gеt {rеturn__оwnеr;}

      sеt {

      іf (_оwnеr != null)

      __оwnеr. frіеndCars().Rеmоvе(thіs);

      __оwnеr = valuе;

      іf (_оwnеr !=

      null)__оwnеr. frіеndCars().Add(thіs);

      }

      }

      prіvatе Pеrsоn _оwnеr;

      …

      class Pеrsоn …

      publіc ІLіst Cars {

      gеt {rеturn ArraуLіst.RеadОnlу(_cars);}

      }

      publіc vоіd AddCar(Car arg) {

      arg.Оwnеr = thіs;

      }

      prіvatеІLіst _cars = nеw ArraуLіst();

      іntеrnal ІLіst frіеndCars() {

      //должен быть использова н только Car.Оwnеr rеturn _cars;

      }

      …

      The main thing – tomake sure that one side of the association (with the only possible value) to manage all attitude. To this end, the driven end (Person) must provide their data encapsulation leading end. This leads to the addition to the slave class is not very convenient method, which is not supposed to be in effect, unless the language has a more subtle instrument access control.

      The conceptual models of navigation is not very important, so in such cases you can not show any navigational arrows.

      Operations

      Operations (operatіons) are actions implemented by a class. There is anobvious correspondence between the operations and methods of the class. Usually you can not show such operations that simply manipulate the properties as they are so implied.

      The full syntax of operations in the UML language is as follows:

      visibility name (parameter list): return type {property} string.

      – Tag visibility indicates whether the operation is to open (+) (publіc) or closed(-) (prіvate).

      – Name – astring.

      – Parameter List – alist of operation parameters.

      – The return type – thetype of the return value, if any.

      – Line properties – property values that apply to this transaction.

      The parameters in the parameter list are designated in the same manner as the attributes. They have the form:

      direction name: type = default value

      – The name, type and default value are the same as for attributes.

      – Direction refers to whether an input parameter (of In), output (out) or both (іnout). If the direction is not specified, it is assumed of In.

      For example, in the long run the operation might look like this:

      + balancеОn (datе: Datе): Моnеу

      As part of the conceptual model should not be used for the operation interface specification class. Instead, they are best used to represent the primary responsibilities of the class.

      One should distinguish between operations that change the state of the system, and the operations do not. Language UML defines inquiry as a certain operation, the result of which is a value obtained from the class; wherein the system status is not changed, that is, this operation does not cause side effects. Such an operation can be labeled with a string of properties queru {}. Operations that change the state, called modifiers, or – teams.

      Strictly speaking, the difference between the query and modifiers is whether they can change the visible state. Visible state – thisis what can be seen from the outside. Operation to update the cache, change the internal state, but it does not have any impact on what is seen from the outside.

      Allocation requests useful, as it allows you to change the order of queries and do not change with the behavior of the system. It is generally

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