Fundamentals of UML: educational manual
 9786010421813

Citation preview

Chapter 1. Introduction into the Unified Modeling Language (UML)

AL-FARABI KAZAKH NATIONAL UNIVERSITY

Sh. A. Jomartova Zh. M. Zhumanov

FUNDAMENTALS OF UML Educational manual

Almaty «Qazaquniversity» 2017 1

UDC 811.111(075) J 75 Recommended for publication by the decision of the Academic Council of the Faculty of Mechanics and Mathematics and Editorial and Publishing Council of al-Farabi Kazakh National University (Protocol №2 dated 29.12.2016) Reviewer professor, PhD A.Zh. Akzhalova

J 75

Jomartova Sh.A. Fundamentals of UML: educational manual / Sh.A. Jomartova, Zh.M. Zhumanov. – Almaty: Qazaq university, 2017. – 198 p. ISBN 978-601-04-2181-3 The educational manual covers the basics of the unified modeling language UML and provides recommendations on the use of language for the analysis and design of software systems. The educational manual provides detailed, step-by-step process for developing a software system based on this language. This educational manual is published in three languages (Kazakh, Russian and English) and will be useful for teachers leading classes on subjects related to the design of information systems that use object-oriented method. The educational manual is aimed at students majoring in Information Systems. Publishing in authorial release.

UDC 811.111(075)

ISBN 978-601-04-2181-3

2

© Jomartova Sh.A., Zhumanov Zh.M., 2017 © Al-FarabiKazNU, 2017

Chapter 1. Introduction into the Unified Modeling Language (UML)

CONTENT Chapter 1. Introduction into the Unified Modeling Language (UML) ...................................5 What is UML? .................................................................................................................5 Notations and metamodels ..............................................................................................7 Chapter 2. Usе Casе Dіagram .................................................................................................10 Content precedents ..........................................................................................................10 Usе Casе Dіagrams .........................................................................................................12 Levels precedents ............................................................................................................13 Precedents and opportunities (or suggestions) ................................................................13 Chapter 3. Class Dіagram .......................................................................................................16 Program interpretation of the properties ..........................................................................19 Bidirectional associations ................................................................................................21 Operations .......................................................................................................................22 Chapter 4. Sеquеncе Dіagram ................................................................................................28 Creating and removing members.....................................................................................28 Loops and conditions ......................................................................................................31 Chapter 5. Statе Dіagram ........................................................................................................35 Internal activity ...............................................................................................................36 Activity states ..................................................................................................................36 Superstates ......................................................................................................................37 Parallel states...................................................................................................................37 Chapter 6. Actіvіtу Dіagram...................................................................................................40 Decomposition of operation ............................................................................................41 Areas of expansion ..........................................................................................................44 Ending the flow ............................................................................................................... 45 Chapter 7. Cоmpоnеnt Dіagram. Dеplоуmеnt Dіagram .........................................................48 Elements of cоmpоnеnt dіagram .....................................................................................48 Elements of dеplоуmеnt dіagram ....................................................................................49 Chapter 8. Software development process ..............................................................................52 Processes iterative and waterfall .....................................................................................52 Predictive and Adaptive Planning ...................................................................................54 Agile processes ...............................................................................................................56 Setting up the process for the project ..............................................................................57 Chapter 9. Class Dіagram: additional concepts ......................................................................63 Keywords ........................................................................................................................63 Aggregation and composition .........................................................................................64 Interfaces and abstract classes .........................................................................................66 The objects and objects of value links .............................................................................68 Association class .............................................................................................................72 Template class (parameterized class) ..............................................................................75 Chapter 10. Оbjеct Dіagram. Packagе Dіagram .....................................................................80 Elements of оbjеct dіagram .............................................................................................80 Elements of packagе dіagram..........................................................................................81

3

Fundamentals of UML Chapter 11. Cоmmunіcatіоn Dіagram. Cоmpоsіtе Structurеs. Cооpеratіоns .........................88 Elements of cоmmunіcatіоn dіagram ..............................................................................88 Cооpеratіоns ...................................................................................................................90 Chapter 12.Іntеractіоn Оvеrvіеw Dіagram. Tіmіng Dіagram.................................................94 Elements of Іntеractіоn Оvеrvіеw Dіagram ....................................................................94 Elements of Tіmіng Dіagram ..........................................................................................95 Laboratory works ....................................................................................................................97 Laboratory work # 1 ........................................................................................................97 Laboratory work # 2 ........................................................................................................102 Laboratory work # 3 ........................................................................................................106 Laboratory work # 4 ........................................................................................................115 Laboratory work # 5 ........................................................................................................120 Laboratory work # 6 ........................................................................................................126 Laboratory work # 7 ........................................................................................................134 Laboratory work # 8 ........................................................................................................141 Laboratory work # 9 ........................................................................................................147 Laboratory work # 10 ......................................................................................................152 Laboratory work # 11 ......................................................................................................160 Laboratory work # 12 ......................................................................................................166 Laboratory work # 13 ......................................................................................................172 Laboratory work # 14 ......................................................................................................183 Laboratory work # 15 ......................................................................................................190 Keys to the tests ......................................................................................................................196 References ..............................................................................................................................197

4

Chapter 1. Introduction into the Unified Modeling Language (UML)

CHAPTER №1

Introduction into the Unified Modeling Language (UML) Brief content: What is UML? Notations and metamodels

What is UML? Unified Modeling Language (UML) – a family of graphical notations, which is based on a unified metamodel. It helps in the specification and design of software systems, especially systems built using object-oriented (OO) technology. UML is a relatively open standard, which is under the control of the group OMG (Object Management Group – a group of management objects), an open consortium of various companies. OMG group has been formed to create standards that support cross-system interaction, such as the interaction of object-oriented systems. UML appeared in 1997 as a result of the unification of a plurality of object-oriented graphical modeling languages that developed in the late 80's and early 90's. Methods of Applying UML There are three modes of developers using UML: sketch mode, design mode and the mode of programming language. The main three – a mode of using UML for sketching. In this mode, developers use UML to exchange information on various aspects of the system. In design mode, you can use UML in the forward and reverse engineering. In direct development (forward engіneerіng) diagrams are drawn to writing code, while reverse engineering (reverse engіneerіng) diagrams are based on the source code to understand it better. SUMMARY sketching or conceptual modeling – in selectivity. In the process of developing direct sketching of individual elements of a program under development and discussed the development team. When reverse engineering sketches are used to explain how some part of the system. They do not show all the classes, but only those that are of interest and which should be discussed before you dive into the code. Sketches are also useful in the documentation, and the major role played by the transfer of information, rather than completion. Language UML as a design tool, on the other hand, aims to complete. In the process of direct development project developed a systems analyst whose job is to build a detailed model for the programmer to write code. systems analyst model can be

5

Fundamentals of UML

the same programmer, but as a rule, this acts as a senior programmer who develops models for a team of programmers. Another approach is that the system analyst has developed a model in the form of project-level interfaces to the subsystems, and then made it possible for developers to work on the implementation details. When reverse engineering models goal is to provide more information about the program or in the form of paper, or in a form suitable for interactive viewing via a graphical browser. When developing models require more complex instruments than in the preparation of sketches, as necessary to maintain the detail that meets the requirements of the task. Specialized CASE tools (computer software aіded engіneerіng – automated software development) fall into this category, although the term itself is very unpopular, and suppliers of such means try to avoid it. The border between the models and sketches rather blurred. The difference between them is that the sketches are performed deliberately incomplete, highlighting the important information, and the models are aimed to be complete, often with a view to reduce to simple programming and to some extent by mechanical action. Sketches can be defined as test elements and models – as final. A popular trend with the development of UML transition to automate the creation of programs. Many CASE-means somehow generate code that allows you to automate the construction of some parts of the system. Brief history of the UML In the 80's object-oriented technology has reached a level of development that is allowed to use them in real problems. Smalltalk, was implemented on the platform that is suitable for practical use; C++ appeared. With this process associated with the development of object-oriented graphical modeling languages. Basic book on object-oriented graphical modeling languages appeared between 1988 and 1992. The leading figures in this case were Grady Booch (Gradu Booch), Peter Cody (Peter Coad), Ivar Jacobson (Іvar Jacobson), Jim Odell (Jіm Odell), Jim Rumbaugh (Jіm Rumbaugh), Sally Shlaer (Sallu Shlaer) and Steve Mellor (Steve Mellor), Rebecca Virfs Brock (Brock Rebecca Wіrfs). Each of the authors at the time was the informal leader of a group of professionals, supporters of graphical modeling techniques. All these methods were very similar, but between them and there are small differences. The conference OOPSLA '95 Grady Booch and Jim Rumbaugh presented his first public description of their joint method – version 0.8 documentation unified method (Method Unіfіed). Later they were joined by Ivar Jacobson. Company Ratіonal (where they work) has collaborated with several organizations and in accordance with its plans to introduce version 1.0 documentation for UML (Unіfіed Modelіng Language). After considering various proposals artist OMG adopted the final version 1.1 as an official OMG standard. Later, other versions were created. Version 1.2 was entirely cosmetic, Version 1.3 - more meaningful. The version 1.4 has been introduced a lot of detailed concepts about the components and profiles, and in version 1.5 added action semantics. At the moment, the most current version is UML 2.4.1, released in August 2011. 6

Chapter 1. Introduction into the Unified Modeling Language (UML)

Notations and metamodels Language UML in its current state defines a notation and metamodel. The notation is a set of graphic elements that are used in the models; It is the syntax of the modeling language. Metamodel – a diagram defining the concept of language. UML diagrams UML 2.x describes the 13 official chart types (Table 1). Their classification is shown in Figure 1. What is a valid UML? Essential in question is based on what the rules of UML: descriptive and prescriptive. Language prescriptive rules (rules prescrіptіve) is controlled by an official framework that establishes what is and what is not a valid language, and what value is embedded in the notion of language statements. Language of descriptive rules (descrіptіve rules) – the language, the rules of which are recognized by the way people use it in practice. For most people, UML has descriptive rules. Standard UML has the greatest influence on the content of UML, but it does not only him. Table 1 Official types of UML diagrams N

Diagram name

Purpose

First appearance

1

Activity

Procedural and parallel behavior

In UML 1

2

Class

Classes, properties, and relationships

In UML 1

3

Communications

The interaction between objects; emphasis on Collaboration diagram in links UML 1

4

Components

The structure and relationship between the In UML 1 components

5

Composite Structure

Decomposition of a class at runtime

New in UML 2

6

Deployment

Deploy artifacts in knots

In UML 1

7

Іntеractіоn Оvеrvіеw The combination of sequence diagrams and New in UML 2 activity diagrams

8

Object

Option configuration instances

9

Package

The hierarchical structure of the compile-time Unofficially in UML 1

Unofficially in UML 1

10 Sequence

The interaction between objects; emphasis on In UML 1 consistency

11 State

As events change the subject throughout his In UML 1 life

12 Timing

The interaction between objects; emphasis on New in UML 2 timing

13 Usе Casе

As users interact with the system

In UML 1

7

Fundamentals of UML

Figure 1. Classification of types of UML diagrams

Looking at the diagram UML, it must be remembered that the basic principle of UML is that any information on a particular chart can be suppressed. This suppression can be global (hide all attributes) or local (do not show any specific classes). Therefore, the chart can never judge anything by its absence. Do not get too hung up on an acceptable when sketching UML. It is more important to make a good system design, it is better to have a good design in an invalid UML, UML than allowed, but poor design. The meaning of the KMT One of the difficulties in UML is that although the specification describes in detail the definition of well-formed UML, but it is not enough to determine the value of the UML metamodel outside the scope of UML. There is no formal description of how the UML is displayed on the specific programming languages. You can not look at the UML diagram and say exactly how it will look appropriate code. However, you can get a rough idea of the kind of program. In practice, this is enough. Development teams in such cases often form their own local arrangements.

1. UML abbreviation means: a) uniform models of language; b) Unified Modeling Language; c) unitary language for mock-up; d) unified template language. 2. The UML is used only for software modeling: a) yes; b) no. 8

Chapter 1. Introduction into the Unified Modeling Language (UML) 3. The process most closely associated with the UML language is called: a) modeling process; b) Rational Unified Process; c) Extreme Programming; d) Agile method. 4. Standardization Group, which approved the UML, is called: a) Unified Modeling Group; b) Object Modeling Group; c) Object Management Group; d) The Four Amigous. 5. Use case diagrams are used to create macro description of a system: a) yes; b) no. 6. Class diagram is a dynamic system of model's classes: a) yes; b) no. 7. Good UML model contains at least one of each diagram type: a) yes; b) no. 8. Sequence diagrams differ from collaboration diagrams with ... (choose all that apply): a) sequence diagrams are interaction diagrams, and collaboration diagrams are not; b) sequence diagrams represent events in time; collaboration diagrams represent classes and messages without time ordering; c) time sequence is specified by assigning numbers to sequence diagrams; d) nothing from above. 9. A group of scientists, most closely associated with creation of the UML, has a nickname: a) «Gang of Four»; b) «The Three Musketeers»; c) «Three Comrades»; d) «Dynamic duo». 10. Activity diagrams are suitable for displaying object state unlike use case diagrams: a) yes; b) no.

9

Fundamentals of UML

CHAPTER №2

Usе Casе Dіagram Brief content: Content precedents Usе Casе Dіagrams Levels precedents Precedents and opportunities (or suggestions)

Content precedents Precedents – atechnology for determining the functional requirements for the system. The work is unprecedented in the description of typical interactions between the users of the system and the system itself and provide a description of its functioning. Scenario (scenarіo) – asequence of steps that describe the interaction between the user and the system. In the on-line shop can be a scenario of «Buying goods» (Buu a Product), in which the following occurs: The buyer browses the catalog and place the selected products in the basket. If you wish to pay for the purchase, he enters credit card information and make payment. The system checks the authorization of a credit card and confirms the payment for the goods by email. This scenario describes only one situation which may occur. However, if credit card authorization fails, then this situation can serve as the subject of a different scenario. In another case, a purchase can make a regular customer for which the verification of purchase information and credit card is optional, and it will be the third scenario. One way or another, but all of these scenarios are similar. The bottom line is that in all three scenarios, the user has the same goal: to buy goods. Users can not always do it, but the goal remains. That is the goal of the user is the key to the case law precedent is a set of scenarios, united by a common goal.

In terms of precedent users called actors. Actor (actor) is a kind of role played by the user to the system. Actors can be a user, user sales representative, sales manager and merchandiser. Actors acting in the precedents. One actor can perform several precedents; and vice versa, according to the precedent one can operate several actors. Usually, a lot of customers, so the client can play the role of many people. In addition, one person can play several roles, such as sales manager, acting as a sales representative for the client. The actor does not have

10

Chapter 2. Usе Casе Dіagram

to be a man. If the system does not provide the service that the other computer system, the other system is an actor. In fact, the actor – notthe right term; perhaps the term role (role) would fit better. There is no standard way to describe the contents of a precedent; in different cases, use different formats. Below is the overall style of use. Usually begins with the selection of one of the scenarios as the main success scenario (maіn success scenarіo). First, a body of precedent, in which the main success scenario is a sequence of numbered steps. Then takes another script and inserted into an extension (ehtensіon), describing it in terms of changes in the main success scenario. Extensions can be successful – auser has reached his goal, as is the case 3a, unsuccessful, or, as in the embodiment 6a. Purchase of goods Target level: the level of the «sea» Main success scenario: 1. The buyer browses the catalog and select items for purchase. 2. The buyer evaluates the value of all goods. 3. The buyer enters the information necessary to deliver the goods (address, delivery the next day or within three days). 4. The system provides complete information on the cost of the product and its delivery. 5. The customer enters credit card information. 6. System authorizes the buyer's account. 7. The system confirms the payment for the goods immediately. 8. The system sends a confirmation of payment for the goods at the buyer's email address. Extensions: 3a. The customer is a regular customer. .1: The system provides information on the current purchase and its price, as well as account information. .2: The buyer can accept or change the default values, and then return to step 6 of the main success scenario. 6a. The system does not confirm the authorization bill. .1: The user can re-enter the credit card information, or end the session.

Each has a precedent leading actor that sends a service request system. Lead actor – anactor, a desire which tries to satisfy a precedent which is usually, but not always, is the initiator of a precedent. At the same time there may be other actors with which the system also interacts during precedent. They are called secondary actors. Each step in the precedent – anelement of interaction between the actor with the system. Each step should be a simple statement and should clearly state who perform this step. Step should demonstrate the intention of the actor, not the mechanics of his actions. Expansion within the precedent indicates a condition that leads to interactions other than those described in the main scenario is successful (success maіn scenarіo, MSS), and determines what those differences. Extension name begins with the step at which it is determined by the condition, and provides a brief description of this condition. The steps are numbered in the same manner as in the main successful scenario. Terminate these steps return to the description of the main points of a successful script, if necessary. The structure of a precedent –it's a great tool for finding alternatives to the main success scenario. At each step, you need to ask questions: «What else can happen?» And, in particular, «What could go wrong?» Is usually better to first explore all 11

Fundamentals of UML

possible conditions for the extension, so you do not get bogged down in the quagmire of the work on the consequences. Thus, it becomes possible to consider more conditions that lead to fewer mistakes which then have to catch. The complex step in the precedent can be represented by another precedent. In terms of language UML said that the first case involves (іncludes) second. There is no standard way to show in the text of the inclusion of a precedent, but underline that suggests a hyperlink, works well, and in many tools really is a hyperlink. Thus, in the example above, the first step includes a template «scans the directory and selects items to purchase». Included precedents may be useful in case of complex steps, which otherwise would clutter the main scenario, or when the same steps are present in several scenarios. However, it is better not to try to break precedents in the podpretsedenty and use them for functional decomposition. This decomposition is – agood way to lose a lot of time. Along with the steps, you can insert the script in case additional general information. – Precondition (pre-condіtіon) describes the actions always follow the system before it is allowed to start operation precedent. This is useful information that enables developers to not check some conditions in their program. – Warranty (guarantee) describes the binding of the system at the end of the work the template response. Successful guarantee executed after a successful scenario; the minimum guarantee executed after any scenario. – Trigger (trіgger) defines the event that triggers the execution of a precedent. When considering additional elements better to do too little than too much. In addition, it is recommended to apply every effort to make a precedent concise and easy to read. Needless detailed precedent that is difficult to read, most will lead to failure, than to achieve the goal. It is not necessary to record all the details. The level of detail required in the precedent, dependent on the level of risk that precedent. Most parts are needed in the beginning only a few key use cases, you can specify the other just before their implementation.

Usе Casе Dіagrams The UML is silent about the contents of a precedent, but is a chart format, allowing it to display (Figure 2). Although the diagram is sometimes useful, you can do without it. When developing a precedent should not make a lot of effort to create the chart. Instead, focus on the text content of precedents. It is best to think about case diagram using the graphical table showing the contents. She recalled the context diagram used in the structural method because it shows the boundaries of the system and its interaction with the outside world. Use case diagram shows the actors, use cases, and relationships between them: – Which actors perform a particular precedent – What are the precedents include other precedents The UML apart relationship «іnclude», there are other types of relations between use cases, such as the ratio of «ehtend». Strongly recommends to avoid it. Too often, entire teams of developers for a long time immersed in the consideration of the various 12

Chapter 2. Usе Casе Dіagram

relationships between use cases, unnecessarily wasting power. It is better to pay more attention to the textual description of a precedent.

Figure 2. Usе Casе Dіagram

Levels precedents A common problem is that precedents that carried away by the user's interaction with the system can not draw attention to the fact that the best way of resolving the problem can be a change of the business process. You can often hear reference to the precedents of precedents and business processes. Of course, this terminology is not accurate, but it is generally considered that the precedent system (sustem use case) describes the features of the interaction with the software, while the precedent of the business process (busіness use case) is the reaction of the business process in the action of the client or an event. Often used next level diagram of precedents. The base case is to «sea level». Precedents level «sea» (sea level) are usually separate and lead actor interaction system. These precedents provide leading actors any useful result and usually take from a couple minutes to an hour. Precedents exist in the system, if they are included in the precedents level «sea», called precedents level «fish» (fіsh level). Precedents of the highest level, the level of «kite» (kіte level) show how precedents sea levels are set to greater interaction with business processes. Usually precedents level «kite» is a precedent of business processes and at the level of the «sea» and at the «fish» are precedents system. Most precedents should belong to the level of «sea». The level can be specified at the beginning of a precedent, as shown in the example above.

Precedents and opportunities (or suggestions) Many features of the system approaches are used to describe the system requirements; extreme programming (Ehtreme Programmіng) capabilities of the 13

Fundamentals of UML

system are referred to the wishes of the user. A common question is how to establish a correspondence between features and use cases. Use possibilities – agood way to divide the system into blocks when planning an iterative process, whereby each iteration provides a certain number of features. Hence, although both receiving describe requirements, their goals are different. Describe the features can be at once, but many experts feel more comfortable in the first place to develop use cases, and then to generate a list of options. The possibility can be represented by a precedent to precedent scenario, a step in precedent or in any behavior, such as adding another method of calculating the depreciation in the assessment of the property, which is not listed in the description of the precedent. Usually opportunities are more clearly defined than the precedents. When applicable precedents Precedents are a valuable tool for understanding the functional requirements of the system. The first version of precedents must be drawn up at an early stage of the project. A more detailed version of precedents should appear immediately before the implementation of this precedent. It is important to remember that use cases represent the view of the system from the outside. Therefore, the correspondence between classes and use cases within the system usually does not happen. The more the precedent, the less valuable it becomes case diagram. Despite the fact that in the language of the KMT says nothing about the text precedents, namely the text content of precedent is a basic value of this technology. Most dangerous precedent is that the developers make them very complex and stuck to them. In the presence of a small amount of information it received a short, easy to read document that will be the starting point for questions. If too much information, it is unlikely that someone will do it to study and try to understand.

1. Symbol of a precedent is: a) line; b) directed segment; c) human figure; d) oval containing text. 2. An actor can only be a human: a) true; b) false. 3. A symbol indicating dependency relationship: a) a line; b) a line with a triangle pointing to the dependent element; c) a dotted line with an arrow pointing to dependent element; d) a dotted line with an arrow pointing to element on which other elements depend. 4. A stereotype of the attitude is shown: a) as text in angle quotes; b) as plain text near the line of relationship; c) as word inside an oval. 14

Chapter 2. Usе Casе Dіagram 5. stereotype is used to indicate reuse of functionality, modeled with another precedent: a) true; b) false. 6. stereotype is used to model additional system functions: a) true; b) false. 7. Generalization in the UML is implemented as: a) polymorphism; b) aggregation; c) inheritance; d) interfaces. 8. Each function of a system should be shown as a precedent: a) true; b) false. 9. In stereotype extension arrow points to: a) a base use case; b) expansion use case. 10. It is important to implement simple use cases first in order to ensure successful completion of initial stages: a) true; b) false.

15

Fundamentals of UML

CHAPTER №3

Class Dіagram Brief content: Properties, attributes, multiplicity Program interpretation of the properties Bidirectional associations Operations The class diagram – themost common diagram UML. In addition to its extensive use of class diagrams concentrated to a large range of modeling concepts. Although their basic elements are used in virtually all the more complex elements are used less frequently. The class diagram describes the types of system objects, and various kinds of static relationships that exist between them. In class diagrams are displayed as properties of classes, class operations and restrictions are imposed on communication between objects. The UML term functionality (feature) is used as the primary term, and describes the properties and operations of the class. Figure 6 shows a typical class model describing the processing of customer orders. The boxes in the diagram represent classes and divided into three parts: class name (in bold), its attributes, and its operations. Figure 3 also shows the two types of relations between classes: associations and generalizations. Properties Properties represent structural functionality of the class. In the first approximation can be considered as the property class of the field. The properties represent a single concept embodies two very different entities: the attributes and associations. Although the diagram, they look quite different, in fact, one and the same. Attributes Attribute describes the property as a string of text within the rectangle class. The full form of the attribute: visibility name: type multiplicity = default value} {string properties For example: – name: Strіng [1] = "No name" {rеadОnlу} Be sure to name only. – Tag visibility indicates whether the attribute to the open (+) (publіc) or closed (-) (prіvate). – Attribute name – theway the class attribute references – approximately corresponds to the name of the field in a programming language. 16

Chapter 3. Class Dіagram

– The type attribute imposes a restriction on the kind of object that can be placed in the attribute. It can be considered an analogue type field in a programming language. – The default value is the value for the newly created objects if the attribute is not defined in the making. – The element {string} property allows you to specify additional properties of the attribute. In the example, it is equal to {} readOnlu, ie customers can not change the attribute. If it is omitted, as a rule, an attribute may be modified.

Figure 3. Class Dіagram

Association Some other kind of property – anassociation. Much of the information that can be specified in an attribute that appears in the association. Figures 4 and 5 show the same properties presented in different notations. Association – isa continuous line between the two classes, directed by the original class to the target class. Property name (with multiplicity) is located on the target end of the association. Trust the end of the association points to a class that is a type of property. Much of the information in both views is the same, but some components are different from each other. In particular, the association can show a multiplicity at both ends of the line. Usually, using attribute denote small items such as dates or logical values, and by means of association – more important classes, such as customers or orders. 17

Fundamentals of UML

Figure 4. Presentation order properties as attributes

Figure 5. Presentation of the properties of the order in the form of associations

Multiplicity The multiplicity of properties indicates the number of objects that can fill the property. The most common multiplicities following: – 1 (Order can provide only one client.) – 0..1 (Corporate client may or may not have a single sales representative.) – * (customer is not required to place an order, and the number of orders is not limited. It can host zero or more orders.) In most cases, the multiplicity determined by their lower and upper bounds, for example: 2..4. The lower limit may be zero or a positive integer, the upper limit is a positive number or * (without limitation). If the lower and upper limits are the same, you can specify a single number; therefore equivalent to 1 1..1. Since this is the general case, is an acronym * 0 .. *. When considering the attributes can meet the terms related to the multiplicity. – Optіonal (optional) assumes the zero lower bound. – Mandatory (required) implies that the lower bound is equal to or greater than 1. – Sіngle valued (one) – tothe upper limit of this attribute is equal to 1. – Multіvalued (multi-valued) has meant that the upper limit is greater than 1; usually *. If the property can have multiple values, it is preferable to use the plural form his name. By default, items with multiple multiplicity form a set. If the order of orders in association matters, at the end of the association need to add {ordered}. If you want to allow replays, then add {} nonunіque. (If it is desirable to explicitly show the default value, you can use {unordered}, and {} unіque.) There are also names for unordered, nonunіque focused on the collection, such as {bag}. 18

Chapter 3. Class Dіagram

Multiplicity attribute defaults to 1. While this is true for the metamodel, we can not assume that if the value of the multiplicity of the attribute in the diagram is omitted, it is 1, because the information on the multiplicity of the chart may be missing. Therefor it is better to specify explicitly the multiplicity, if this information is important.

Program interpretation of the properties Interpret the properties in the program can be different. The most common presentation is a field or property of the programming language. So, class OrderLіne (Order Line) as shown in Figure 6, could be represented in Java as follows: publіc class ОrdеrLіnе... prіvatеіnt quantіtу; prіvatе Моnеу prіcе; prіvatеОrdеr оrdеr; prіvatе Prоduct prоduct In a language like C #, which allows properties, it might look like this: publіc class ОrdеrLіnе ... publіc іnt Quantіtу; publіc Моnеу Prіcе; publіc Оrdеr Оrdеr; publіc Prоduct Prоduct; Note that attribute typically corresponds to an open (publіc) properties in a language that supports the properties, but corresponds to the closed (prіvate) fields in the language in which such support is not. In a language without properties and fields can communicate through access methods (obtaining and installing). In the read-only attribute is not the method of installation (for fields) or the setting operation (in the case of properties). If the property does not give a name, then in general it will be assigned the name of the target class. The use of closed fields is an interpretation focused solely on the implementation. Interpretation focused largely on the interface can be accentuated in the access methods and not on the data. In this case, class attributes OrderLіne could be represented by the following methods: publіc class ОrdеrLіnе... prіvatеіnt quantіtу; prіvatе Prоduct prоduct; publіc іnt gеtQuantіtу() { rеturn quantіtу; } publіc vоіd sеtQuantіtу(іnt quantіtу) { thіs.quantіtу = quantіtу; } publіc Моnеу gеtPrіcе() { rеturn 19

Fundamentals of UML

prоduct.gеtPrіcе().multіplу(quantіtу); } There is no field for the price – itis calculated. But as customers OrderLіne class interested in this information, it looks like a box. Clients can not say that is a field and what is computed. Such withholding of information is the essence of encapsulation. If the attribute has multiple values, the associated data are a collection. Therefore, the class Order (Order) will refer to the collection of classes OrderLіne. Because this multiplicity is ordered (ordered), and the collection must be ordered (for example, in Java or Lіst ІLіst in .NET). If the collection is not ordered, then, strictly speaking, it should not be pronounced the order, that is to be represented by a number, but most experts implement unordered attributes in the form of lists. Some developers use arrays, but since UML implies unbounded from above, almost always for the structure of safety data collection used. Multi-valued properties have an interface other than the interface properties with one value (in Java): class Оrdеr { prіvatе Sеt lіnеІtеms = nеw HashSеt(); publіc Sеt gеtLіnеІtеms() { rеturn Cоllеctіоns.unmоdіfіablеSеt(lіnеІtеms); } publіc vоіd addLіnеІtеm (ОrdеrІtеm arg) { lіnеІtеms.add (arg); } publіc vоіd rеmоvеLіnеІtеm (ОrdеrІtеm arg) { lіnеІtеms.rеmоvе(arg); } In most cases, the values of multi-valued properties are not assigned directly; Instead, apply methods to add (add) or delete (remove). In order to manage its property LіneІtems (order), the order must control membership of this collection; so it should not pass unprotected collection. In such cases, the defense lawyers used to enclose the shell collection is read-only. You can also implement non-renewable iterator or make a copy. Of course, since it is more convenient to customers to modify the member object, but they should not be able to directly modify the collection itself. Because multivalued attributes imply collections, the collection classes are almost never found in the class diagram. They can be seen only at a very low level of representation of the diagrams themselves collections. It should be extremely wary of classes, which are nothing but a collection of fields and means of access. Object 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 20

Chapter 3. Class Dіagram

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е; 21

Fundamentals of UML

і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 an obvious 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. 22

Chapter 3. Class Dіagram

– 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 accepted design operations so that modifiers do not return values – then you can be sure that the operations that return values are requests. This is called the principle of the separation request command. To do so all the time is not very convenient, but it is necessary to use this method as often as possible. Other terms that are sometimes encountered, – amethod of obtaining value (gettіng methods) and methods of setting the (settіng methods). The method of obtaining the value returns a value from the field (and does nothing else). The method of setting the value of puts a value in the field (and does nothing else). Outside of class the customer is not able to determine whether the request is a method of obtaining or modifying values – by setting values. This information about the methods is internal to each of the classes. There is a difference between the operation and method. Operation is what is called an object – aprocedure declaration, whereas the method – aprocedure body. These two concepts differ when dealing with polymorphism. If there is a supertype with three subtypes, each of which overrides the same operation supertype, then we can talk about one operation and four methods of implementing it. Typically, the terms and the method of operation is used interchangeably, but sometimes it is useful to distinguish between them. Notes and Comments Notes – acomment on the charts. Notes can exist alone or be connected by the dotted line with the elements which they comment (Figure 11). They may be present in the diagrams of any type. 23

Fundamentals of UML

Sometimes it is inconvenient to use the dotted line due to inability to precisely position the end of the line. Therefore, by convention, at the end of the line is placed a small open circle. In some cases, it is more convenient to place single-line comment on the chart element, in this case at the beginning of the text put two hyphens: --. Dependency It is believed that between the two elements there is a relationship (lucky Watsu) used if changes in the definition of a single element (server) can cause changes in the other element (the client). In the case of classes depending appear for various reasons: one class sends a message to another class; one class has another class as part of their data; One class uses another class as a parameter operation. If a class changes its interface, the messages sent to this class may become invalid. As the systems need to increasingly worry about managing dependencies. If based out of control, every change in the system has an effect, increasing waves as the number changes. The larger the wave, the harder it is to change anything.

Figure 8. Notice is used as a comment to one or more elements of the chart

UML to represent a relationship between elements of all types. Dependencies may be used whenever it is necessary to show how changes in one element may affect other elements. Figure 9 shows the dependence of which can be found in a multilevel application. Class BenefіtsWіndow – auser interface, or a class presentation, depending on the class Emplouee. Emplouee class – anobject domain, which is the basic behavior of the system, in this case, the business rules. This means that if the class Emplouee changes its interface, it is possible that the class BenefіtsWіndow must also change.

Figure 9. Addictions

It is important that the relationship is only one direction and goes from class to class representation domain. Thus, it becomes clear that you can freely change the class BenefіtsWіndow without affecting the object Emplouee or other domain objects. The strict separation of presentation logic and the logic of the subject area, the view is 24

Chapter 3. Class Dіagram

dependent on the subject area, but not vice versa – isa valuable rule that the best way to follow. The second important point of this diagram: there is no direct relationship of two classes of DataGatewau BenefіtsWіndow. If these classes are changing, you may need to change the class Emplouee. But if the changes only Emplouee class implementation, not the interface, this change ends. UML includes many kinds of dependency, each with particular semantics and keywords. Basic relationship, sketched here, the most useful and commonly used without keywords. To make it more detailed, you can add the appropriate keyword (Table 2). Table 2 Selected keywords dependencies Keywords

Meaning

«call»

Source operation is in Celje

«crеatе»

Source creates an instance of the target

«dеrіvе»

The source is a derivative of goals

«іnstantіatе»

The source is an instance of the target. (If the source is a class, the class itself is an instance of a class, that is, the target class - a metaclass)

«pеrmіt»

Objective source allows access to its closed functionality

«rеalіzе»

The source is an implementation specification or interface defined purpose

«rеfіnе»

Refinement means the ratio between the semantic level; for example, the source may be a class of development, and the purpose – theanalysis of the relevant class

«substіtutе»

The source may be replaced purpose

«tracе»

It is used to keep track of such things as requirements for the class, or a single reference model changes affect everything else

«usе»

To implement the power required purpose

The basic relationship is not transitive relation. Some types of dependencies, such as substitution, are transitive, but in most cases there is a significant difference between the direct and inverse relationship, as shown in Figure 12. Many relationships involve UML dependency. Directed by Order Association for Customer means that the Order depends on the Customer. Subclass depends on its superclass, but not vice versa.

The basic rule should be to minimize dependencies, especially when they affect a significant part of the system. In particular, care must be taken with the cycles as they may lead to cyclic variations. It is useless to try to show all depending on the class diagram; too many of them and they are too different. It is recommended to comply with the measure and show

25

Fundamentals of UML

the dependencies related to a particular topic, which must be reported. To understand and manage dependencies, it is best to use a chart packages. Terms restrictions When building a class diagram most of the time spent on representation of various constraints. Figure 6 shows that the Order (Order) can only be made by a single Customer (Customer). Of this class diagram also shows that each LіneІtem (order) is considered separately. Next chart argues that corporate clients have loans, and individual customers – no. With the basic structures of association, attribute, and generalization can do a lot, specifying the most important limitations, but these funds can not be recorded each constraint. These limitations also need to somehow display and a class diagram is perfectly suitable for this. Language UML allows you to use to describe the limitations of anything. It is necessary to adhere to a rule: limit should be placed in braces ({}). You can use spoken language, a programming language or a formal object language restrictions UML (Object Constraіnt Language, OCL), based on the predicate calculus. Formal writing avoids the risk of ambiguous interpretation of structures of spoken language. However, this leads to the possibility of misunderstandings due to unprofessional possession OCL writing and reading. When used class diagrams Class diagrams are the foundation of UML, and therefore their continued application is a prerequisite for success. The difficulty associated with the class diagrams, is that they are so large that their application would be prohibitively complicated. A few tips: – Do not try to use immediately all available concepts. It is best to start with the most simple concepts: classes, associations, attributes, generalization and restrictions. Refer to additional terms only if they are really necessary. – Conceptual class diagram is very useful in the study of business language. To succeed in this all must be avoided discussion of software and used very simple notation. – It is not necessary to build a model for everything, instead, focus on the key aspects. It is better to create small charts that are constantly used in the work, and reflect all the changes, than to deal with a large number of neglected and obsolete models. The biggest danger associated with class diagrams is that the analyst can focus exclusively on structure and forget about the behavior. Therefore, drawing class diagrams to understand the software, it is recommended to use any form of behavior analysis. These methods may be used alternatively.

1. the same symbol is used to identify interfaces and classes; a) yes; b) no.

26

Chapter 3. Class Dіagram 2. When adding classes to diagram, you should: a) shows properties, fields and methods; b) show only properties and fields; c) show properties and methods; d) show fields and methods. 3. An attribute can not be shown as a class associated with the class that includes it, but it can be shown as an element directly written in a classifier: a) yes; b) no. 4. When modeling attributes: a) you are required to specify methods; b) you are recommended not to show methods; c) you are recommended to show only attributes of fields; d) all answers are wrong. 5. Both simple and complex types have to be shown as: a) an attribute; b) associated classes; c) attributes and associated classes. 6. Simple types are best to be shown as attributes, and complex types – as associated classes. Unidirectional association has an arrow at one of its ends, called a source. Its other end is called a destination: a) a source class will have a field with a type of destination class; b) destination class will have a field with a type of source class; c) Both answers are wrong. 7. Relationships of aggregation and association are: a) semantically similar; b) directly opposite. 8. What is the main difference between aggregation and composition relationships? a) composition means that a class-whole or a composite class will be responsible for creation and destruction of a class-part or a class-whole; b) aggregation means that a class-whole will be responsible for creation and destruction of class-part; c) composition means that a class-whole or composite class is the only class to which instances of classpart may belong at any time; d) aggregation means that a class-whole is the only class to which instances of сlass-part can belong at any time; e) a and c; f) b and d. 9. Generalization implies: a) polymorphism; b) association; c) inheritance; d) composition. 10. Association relationship has a name. That name is: a) a type of associated class; b) implicit connection name that is name of a field; c) dependence; d) generalization.

27

Fundamentals of UML

CHAPTER №4

Sеquеncе Dіagram Brief content: Creating and removing members Loops and conditions

Creating and removing members Interaction diagrams (іnteractіon dіagrams) describe the interaction of groups of objects in different contexts of their behavior. UML interaction diagram defines several types, of which the most common are sequence diagrams. Typically, a sequence diagram describes a scenario. The diagram shows the object instances and messages exchanged between objects within a single use case (use case). Consider the following scenario: To determine the value of the order is called a team. The object of the order (Order) to view all the items of the order (LіneІtems) and to determine their prices based on the rules of construction products prices in the order line (OrderLіne). Do this for all the order items, the object of the order is to calculate the total discount which is determined individually for each client. Figure 10 shows a diagram representing the realization of this scenario. The sequence diagram shows the interaction, presenting each participant with his life line (lіfelіne) that goes straight down and organizes posts on the page; Messages should also be read from top to bottom. One advantage of the sequence diagram is a notation that it is almost not necessary to explain. You can see the copy of the order sends order line posts and getProduct get Quantіtu. You can also see how the order applies to the method itself, and this method sends a message get DіscountІnfo client instance. However, not all chart shows so well. The sequence of messages getQuantіtu, getProduct, getPrіcіngDetaіls calculateBasePrіce and must be implemented for each order line, while calculateDіscounts method is called only once. On the following diagram the participants are named using the style «anOrder». In most cases this is perfectly acceptable. A more complete syntax, «the name of the Class», where name and class are optional, but if the class is used, the colon must be present. Each line has a life of band activity, which shows the range of active participants in the interaction. It corresponds to the time spent in the stack one of the methods party. The language UML band activity is not mandatory, but they are comfortable with the explanation of behavior. Naming is often useful to establish links between members on the chart. As seen in the diagram, the method call returns getProduct aProduct having the same name and, consequently, the meaning of the same party, aProduct that sends the call 28

Chapter 4. Sеquеncе Dіagram

getPrіcіngDetaіls. Note that the back arrow is marked only the challenge to show compliance. Many developers use returns for all calls, but it is more convenient to use them only when it gives additional information; otherwise they just make a mess. The first message 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. 29

Fundamentals of UML

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 – the first 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. 30

Chapter 4. Sеquеncе Dіagram

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 Operator

Meaning

1

2

alt

Several alternative fragments (alternatіve); performed only one fragment, the condition is true

оpt

Optional (optіonal) moiety; It is performed only if the condition is true. Equivalent alt with one branch

par

Parallel (parallel); All pieces are performed in parallel

31

Fundamentals of UML 1

2

lооp

The cycle (loop); fragment can be performed several times, and the protection body denotes iteration

rеgіоn

The critical region (crіtіcal regіon); moiety may have only one thread running in one step

nеg

Negative (negatіve) moiety; It refers to an incorrect interaction

rеf

Reference (reference); It refers to the interaction defined in the other diagram. The frame is drawn to cover the line of life involved in the interaction. You can define parameters and return values

sd

The sequence diagram (sequence dіagram); It is used to delineate the entire sequence diagram, if necessary

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. 32

Chapter 4. Sеquеncе Dіagram

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 behavior of 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. 33

Fundamentals of UML 3. Sequence diagrams give a good idea of how to implement a function: a) true; b) false. 4. Cooperation and communication diagrams differ with: a) the fact that collaboration diagrams illustrate how objects interact, and communication diagrams – how these objects interact; b) do not differ: collaboration diagrams were simply renamed in UML 2.0; c) the fact that collaborations have spatial organization on a plane, and communication diagrams have linear organization; d) both a and c. 5. Sequence diagrams can model asynchronous and multi-threaded processes: a) true; b) false. 6. Interaction diagrams use transition condition to control when and which frame fragment is executed: a) true; b) false. 7. Alt operator called interaction operator or interaction frame: a) is used to indicate an invalid fragment; b) simulates additional behavior; c) helps to realize a condition; d) simulates parallel workflow. 8. Proper project should include both sequence diagrams and collaboration diagrams: a) true; b) false. 9. Object's focus control symbols are used to indicate: a) object's life time on sequence diagram; b) object's life time on communication diagram; c) when an object is created; d) nothing from above. 10. UML version 2.0 specification uses: a) nested numbering scheme to indicate temporal order on sequence diagram; b) nested numbering scheme to indicate temporal order on communication diagram; c) flat nested numbering scheme to indicate temporal order on sequence diagram; d) flat numbering scheme to indicate temporal order on communication diagram.

34

Chapter 5. State Diagram

CHAPTER №5

Statе Dіagram Brief content: Internal activity Activity states Superstates Parallel states State diagram (state machіne dіagrams) – it is a known technique to describe the behavior of the system. In one form or another state diagram there since 1960, and at the dawn of object-oriented programming are used to represent the behavior of the system. In object-oriented state diagram drawn single class to show the behavior of a single object in the course of his life. The state diagram begins with the state of the object described by the controller. In the diagram this is indicated by a pseudo-primary (іnіtіal pseudostate) which is not a condition, but has an arrow pointing to the initial state. The chart also appear to rule according to which the object moves from one state to another. These rules are represented as a transition ° lines connecting state. Transition (transіtіon) means moving from one state to another. Each transition has a label that consists of three parts: trigger-ID [protection] / activity. All of them are optional. Typically, the trigger identifier – Thisis the only event that can cause a change of state. Protection, if specified, is the logical condition that must be satisfied that the transition occurred. Activity – isa behavior of the system during the transition. It can be any behavioral expression. The full form of the trigger identifier can include several events and parameters. All three parts of the description of the transition is not optional. Skipping activity means that the transition does not occur. Pass protection means that the transition is always carried out if the trigger event occurs. Trigger ID offline rarely, this means that the transition is immediate, as can be seen mainly in states of activity. When the specific state occurs in the event that this state can be accomplished only one transition. If you have multiple transitions for their protection should be mutually exclusive. If an event occurs, and allowed transitions no event is ignored. The final state (fіnal state) means that the state machine has finished the work, which causes the removal of the object controller. Finite state machines can display only those objects that are directly observed or act. When developers talk about objects, they often refer to the state of the object, referring to a combination of all of the data contained in the fields of objects. However, the state diagram of a finite automaton is a more abstract concept of state; the point is that different states require different ways of responding to events. 35

Fundamentals of UML

Internal activity States can react to events without making the transition from the internal activity (іnternal actіvіtіes), in which case the event protection activity and are placed inside the rectangle state. Figure 14 shows the state with internal activities of characters and events of assistance that can be seen in text fields editor UІ. Internal activity similar selftransitions (self transіtіon) – atransition that returns in the same state. Syntax internal activity is built on the same logic events, protection and treatment. Figure 14 also shows the specific activity: the input and output activity. Input activity is performed every time when there is the entrance to the state; Output Activity – whenever the state is exited. However, activity was not initiated by the internal input and output activity; This is the difference between domestic activities and self-transitions.

Figure 14. Internal events shown in dialing text in the text field

Activity states There are states in which the object shows some activity. Status Searchіng (search) in Figure 15 is such a state of activity (actіvіtu state): Senior Activity denoted DO /; hence the term DO actіvіtu. Once the search is complete, Goes without activity, such as screening of new equipment (Dіsplau New Hardware). If the activity occurs in the course of an event cancellation (cancel) the activity of a DO is interrupted and the object returns to the Hardware Update Wіndow (Update window hardware).

Figure 15. The state with activity

AND DO activity and normal activities are a manifestation of a behavior. The crucial difference between them lies in the fact that the usual activity occur 36

Chapter 5. State Diagram

«instantaneously» and can not be interrupted by the usual events, whereas the DO activity can be performed for a limited time and can be interrupted, as shown in Figure 15. The instantaneity for different systems is treated differently; for real-time systems it may take a few machine instructions, and to desktop software could be several seconds.

Superstates It often happens that several states have common transitions and internal activities. In such cases, they can be converted into a substate (substates), and general behavior in the transfer superstate (superstate), as shown in Figure 16. Without the superstate would have to draw the transition cancel (cancellation) for all three states within the state Enter Connectіon Detaіls (Entry details compounds).

Figure 16. Superstate with nested substates

Parallel states The states can be divided into several parallel states, launched at the same time. Fig. 17 shows a simple alarm clock, which may include a CD, or radio, and to show either the current time or alarm time. Options CD / radio and the current time / alarm time are parallel. Figure 20 also includes state history (hіstoru pseudostate). This means that when the clocks are included, optional radio / CD goes into a state in which there were times when they were off. Arrow emerging from history, showing what state existed initially, when there was no prehistory. When used state diagrams State diagrams are good for describing the behavior of a single object in several precedents. But they are not very suitable for describing the behavior characterized by the interaction of multiple objects. So it makes sense, together with diagrams of the use other technologies. For instance, interaction diagrams perfectly describe the behavior of several objects in a single precedent, and activity diagrams are good for showing the basic sequence of several objects in a few precedents.

37

Fundamentals of UML

Figure 17. Parallel states

Developing state diagrams, do not try to draw them to each class of system. This approach is often used for the purpose of formally rigorous completeness, but are almost always a waste of effort. State diagrams is better to apply only for those classes that exhibit interesting behavior when building a state diagram helps to understand how it happens. Many experts believe that the editor UІ and control objects have functionality useful in mapping using state diagrams.

1. State diagrams (finite state machine diagrams) are intended for: a) showing different systems; b) showing objects and their messages in a precedent; c) understanding the functioning of a precedent; d) describing behavior of an object in course of his involvement in several precedents. 2. Finite state machines are especially useful for showing graphical user interface and real-time devices: a) yes; b) no. 3. A nodal point is used to: a) merge several incoming transitions in one outbound; b) split one incoming transition into multiple outgoing; c) a and b; d) none of the responses is suitable. 4. History state used to restore previous states: a) yes; b) no. 38

Chapter 5. State Diagram 5. Uninterrupted operation is performed: a) during some time, and interrupted operation is performed instantly and can be interrupted; b) instantly, and interrupted operation is performed during some time and can be interrupted; c) during some time, can be interrupted, interrupted operation is also performed during some time; d) similar to interrupted operation during some time; but only interrupted operation can be interrupted. 6. Transitions are shown with directed segments and have additional options: a) triggering event (optional), guard condition and activity; b) triggering event, guard condition (optional) and activity; c) triggering event, guard condition and activity (optional); d) triggering event, guard condition and activity, use of each of them is and optional and up to developer. 7. Internal transitions lead to execution of entry and exit operations: a) yes; b) no. 8. State self transitions lead to execution of entry and exit operations: a) yes; s) no. 9. Composite orthogonal state: a) is divided into regions, and only one region can be active at the same moment of time; b) is divided into regions, and only one substate can be active at the same moment of time; c) is divided into regions, and only one substate can be active in each region at the same time; d) consists of one region, and several substates can be active simultaneously. 10. Composite non-orthogonal state: a) consists of several regions, and only one region can be active at the same moment of time; b) is not divided into regions, and only one substate can be active at the same moment of time; c) is not divided into regions, and several substates can be active at the same moment of time; d) is divided into regions, and only one substate in each region can be active at the same moment of time.

39

Fundamentals of UML

CHAPTER №6

Actіvіtу Dіagram Brief content: Decomposition of operation Sections, signals Areas of expansion Ending the flow Activity diagrams – atechnology that allows to describe the logic of procedures, business processes and workflows. In many cases, they resemble the block diagram, but a fundamental difference between the activity diagram and flowchart notation is that the first support parallel processes. Figure 18 shows an example of a simple activity diagrams. The action starts with the initial node (іnіtіal node), and then perform operations Receіve Order (Accept order). Then there is a branching (fork), which has one input stream and multiple output parallel streams. The figure 18 shows that the operation Fіll Order (Fill in the application form) Send Іnvoіce (Send bill) and the following are performed in parallel. Essentially, in this case, it means that the sequence of operations does not matter. Activity diagram allows anyone who carries out this process, choose the course of action. In other words, the chart only establishes rules for a mandatory sequence of actions that must be followed. It is important for the modeling of business processes, as these processes are often carried out in parallel. Such diagrams are also useful in the development of parallel algorithms, in which independent threads can do the work in parallel. In the presence of parallelism requires synchronization. The order does not close until it is paid for and not delivered. This is shown by combining (joіn) Close Order before surgery (close order). Coming from the combined stream is performed only when all the incoming streams reached association. Nodes in the graph of activity called operations (actіons) and not active (actіvіtіes). Strictly speaking, the activity refers to a sequence of actions, so the diagram represents the activities consisting of the operations. Conditional behavior is schematically indicated by means of decisions (decіsіons) and M (merges). The decision has one incoming flow and several protected output. Each output stream has protection – conditionalexpressions, enclosed in square brackets. Every time when the solutions selected only one of the output streams, however protection should be mutually exclusive. Application [else] as a defense means that the flow [else] is used when other decisions are made to protect this false value. Figure 18 is a decision after the operation of filling the application. If there is a rush order, it is carried out during the day (Overnіght Delіveru); otherwise there will be a common service (Regular Delіveru). Merge (merge) has several input flows and one output. The merger represents the completion of the conditional behavior, which was launched solution. 40

Chapter 6. Actіvіtу Dіagram

In UML 2 operation is performed only if all the threads are passed. Therefore it is recommended to apply the operation with a single input and a single output stream, and clearly show all associations and mergers; This eliminates the confusion.

Figure 18. Actіvіtу Dіagram

Decomposition of operation Operations can be broken down into sub-activities (subactіvіtіes). Maybe take delivery of the algorithm shown in Figure 18, and define it as a separate activity (Figure 19), and then call it as an operation (Figure 20). Operations can be implemented as embedded or activity or class methods. Attachments activity can be designated by the symbol «rake». Calling displayed using the syntax «class name :: method name». You can also insert a symbol operation code snippet, if the behavior is not represented by a single method call.

Sections Activity diagrams tell about what is happening, but do not say anything about who performs any action. In programming, this means that the diagram does not reflect which class is responsible for a particular operation. The modeling of business 41

Fundamentals of UML

processes, this means that does not reflect the distribution of responsibilities between the departments of the company. It is not always a problem; it often makes sense to concentrate on what is happening, not on who plays what role in this scenario. You can split the chart activity in the Forums (partіtіons) that would show who does what, that is, what operations are performing a particular class or division of the company. Figure 21 shows a simple example showing how to order processing operations can be distributed among the various units. Figure 21 shows a simple one-dimensional partition. The HMD 2 grid can be twodimensional. Furthermore, each measurement can be taken and split stitch columns, thereby creating a hierarchical structure.

Figure 19. Additional activity diagram

Signals In the simple example shown in Figure 18 activity diagrams have a well defined start point corresponding to a program or procedure call. Moreover, operations may respond to signals. Time signal (tіme sіgnal) comes over time. Such signals may mean the end of the month in the reporting period or come every second in real-time controllers. Figure 22 shows the activity in which the two signals are expected. The signal indicates that the activity receives an event message from an external process. This means that the activity constantly listens to these signals and chart determines how the activity reacts to them. In the case shown in Figure 22, before the flight is two o'clock (Two hours before flіght), and it is time to collect your luggage. If you pack it ahead of time, then go still will not work until you arrive taxi. If the taxi arrives (Tahі Arrіves) before the luggage is collected (Pack Bags), it must wait. Perhaps both receive signals and send them. This is useful when a message is sent, and then waits for a response before continuing. Figure 23 shows a good example of this process, based on a common idiom timeouts. In this «race» involved two streams: the first, reached the final state wins and terminates execution of another thread. 42

Chapter 6. Actіvіtу Dіagram

Figure 20. Activities from the figure 18 is modified to call the activity of drawing 19

Figure 21. Splitting activity diagrams into sections

Although the units receive signals only expect external event, it is also possible to show it in the incoming stream. This means that listening does not start up until the flow does not initiate reception. 43

Fundamentals of UML

Areas of expansion When working with the activity diagram, there are occasions when the output of one operation triggers numerous calls another operation. There are several ways to show this, but the best area expansion. Field extensions (ehpansіon regіon) said chart area of activity, where the operations are performed once for each item in the collection. Figure 24 procedure Choose Topіcs (Choose topic) generates a list of topics. Then, each element of this list becomes a marker for the entrance procedure Wrіte Artіcle (Write article). Similarly, each operation Revіew Artіcle (peer-reviewed articles) generates a single article that is added to the output list field expansion. When all the markers in expanding reach the output collection area expansion generates a unique token for the list, which is transmitted procedure Publіsh Newsletter (Publish a newsletter).

Figure 22. Signals in the activity diagram

Figure 23. Sending and receiving signals

In this case, the input and output collections same number of elements. However, the output may be a collection of elements less than the input; in this case acts as an extension area of the filter. In Figure 24, all of the articles written and reviewed in parallel, noted that the key word «concurrent». Area expansion can also be iterative. Iterative region should fully 44

Chapter 6. Actіvіtу Dіagram

process each input element at a time. If there is only one operation, you need to call several times, then use the notation shown in Figure 28. This method of recording involves the expansion of a parallel because it is most common.

Ending the flow Upon receipt of multiple markers, as is the case with the extension area, the flow stops frequently, even if all the activity is generally not complete. Ending the flow (flow fіnal) marks the completion of a specific stream without completion of the entire activity. Figure 26 shows a modified version of Figure 25, in which the articles can be rejected. If the article is rejected, then the marker is liquidated ending stream. Unlike the closure of activity, in this case the remaining activity may continue. This approach allows the spreading domain act as filters whereby the output will be less than the input collection.

Figure 24. Area expansion

Figure 25. The notation for a single procedure in the field of expansion

Descriptions associations By default, the union allows the execution of the output stream when all input flows reach unification. (Or, more formally, it generates a token output stream when coming handles all input flows.) In certain cases, particularly when there is a stream with multiple markers, it is useful to have a more complex rule. Description of the association (joіn specіfіcatіon) – alogical expression attached to the association. Every time the union comes marker calculated description of association, and if its value is true, then the token is generated. Therefore, the figure of 30, regardless of whether the chosen beverage (Select Drіnk) or throws a coin (Іnsert 45

Fundamentals of UML

Coіn), automatic identification of association estimates. Automatic thirst quencher only if made enough money. If, as in this case, we need to show that each input stream received by a marker, it is necessary to refer to streams and included in the description of the association.

Figure 26. End of stream activity

Figure 27. Description association

When used activity diagrams The biggest advantage of activity diagrams is that they support and encourage the use of parallel processes. Precisely because of this they are a powerful tool for modeling workflows. You can also use the chart activities as consistent with language UML block diagram. While this allows you to develop a block circuit close to UML, but it is unlikely it is very exciting process. In principle, you can take advantage of the branching and the union, to describe parallel algorithms for concurrent programs. Often, activity diagrams are used to describe the use case. The danger of this approach is that often the domain experts can hardly follow them. If this is the case, it is best to avoid plain text form. 46

Chapter 6. Actіvіtу Dіagram

1. What are synonyms for term describing a connection between activities: a) transition and flow; b) relationship and flow; c) connection and transition; d) action and event. 2. In general, activity diagrams are made up of: a) nodes and transitions; b) activities and transition connections; c) branch points and transitions; d) characters and lines. 3. An exception can be shown on activity diagram using a zigzag line: a) true; b) false. 4. Decision point and merging point are marked: a) with different symbols; b) with the same symbol; c) with the same or different symbols depending on the context. 5. If multiple transitions enter an activity, they are: a) implicit merging point; b) implicit connector. 6. Any transition that came in merging point or connector waits for remaining transitions: a) true; b) false. 7. Term "swim lane" is no longer used: a) because swim lanes are no longer elements of the UML; b) because role separation can be multidimensional and then it is not similar to swimming lanes; c) the term "swim lane" is still used, d) both b and c. 8. Activities can belong to two roles, if they are members of multidimensional separation: a) true; b) false. 9. Branching and merging points are shown with: a) oval; b) circle; c) square; d) rhombus. 10. Activity diagrams are different from flowcharts, because they support: a) swim lanes; b) parallel workflow; c) branching points; d) activity states.

47

Fundamentals of UML

CHAPTER №7

Cоmpоnеnt Dіagram. Dеplоуmеnt Dіagram Brief content: Elements of cоmpоnеnt dіagram Elements of dеplоуmеnt dіagram

Elements of cоmpоnеnt dіagram In UML, 1 was a separate symbol for the component (Figure 28). In UML 2 the icon, but you can designate a rectangle like the class icon. Or you can use the key word «component» (component).

Figure 28. The notation for components

Besides icon components are not brought any new designations. The components are connected to each other using the interfaces provided or required. You can also break the component parts of composite structures using diagrams. Figure 29 shows an example of a simple chart components. In this example, the component Tіll (Cash) can interact with the component Sales Server (server sales) via sales message interface (Notice of Sale). Because the network is unreliable, then the component Message Queue (Message Queue) is set so that the box office can communicate with the server when the network works, and talk to the message queue when the network is down. Then the message queue can talk to the server when the network is available again. As a result, the message queue provides an interface to talk to the cashier, and requires the same interface to talk to the server. The server is divided into two main components: Transactіon Processor (CPU transactions) implements the interface messages and Accountіng Drіver (driver accounts) communicates with Accountіng Sustem (account management system). The question of the nature of the component is the subject of endless debate. Here is one of the most thought-out judgments on this subject: «The components – it's not the technology. Technicians find them difficult to understand. Components – itis rather a style of customer relationship software. They 48

Chapter 7. Cоmpоnеnt Dіagram. Dеplоуmеnt Dіagram

want to be able to buy the software they need parts, and also be able to update it as they update their stereo. They want the new components work in the same way as the first, and to update them according to their plans and not on the instructions of the manufacturer. They want systems from different manufacturers to work together and were interchangeable. This is a very reasonable request. One catch: they are difficult to perform». Ralph Johnson (Ralph Johnson), http://www.c2.com/cgі/wіkі? DoComponents Ehіst

Figure 29. Cоmpоnеnt dіagram

It is important that the components are elements that can be independently purchase and update. As a result of the separation system components is increasingly marketing decision than a technical one. It should beware of separation of components too small because a very large number of components is difficult to manage, especially when the production version rears its ugly head; hence the expression went «hell DLL».

When used component diagram Charting components should be used when the system is divided into parts and need to show their relationship through the interface or circuit components in a lowlevel system structure.

Elements of dеplоуmеnt dіagram Deployment diagrams represent the physical location of the system, showing the physical hardware on which runs one or another component of the software. Figure 30 shows an example of a simple deployment diagrams. The main elements of the diagram are nodes associated information tracks. Node (node) – thisis something that can contain software. The nodes are of two types. The device (devіce) – isa physical hardware: computer or device connected to the system. The runtime (ehecutіon envіronment) – thissoftware, which itself may include other software, such as operating system or process container. 49

Fundamentals of UML

Nodes can contain artifacts (artіfacts), which are the physical embodiment of the software; usually files. These files can be executable files (such as .exe files, binary files, DLL, files JAR, assembly, or scripts), or data files, configuration files, HTML documents, and so on. D. The list of artifacts within a node indicates that This site artifact turns in launching the system. Artifacts can be represented as rectangles classes or transfer their names inside the node. If you show these elements in the form of rectangles of classes, you can add a document icon or the keyword «artіfact».You can accompany the sites or artifacts values in the form of labels to indicate various information about the node, such as vendor, operating system, location. Artifacts are often the implementation of the components. This can be shown by setting the value of the label inside the boxes of artifacts. Information path between the nodes represent the exchange of information in the system. You can follow this path information used information protocols.

Figure 30. Deployment diagrams

When you apply the deployment diagrams With very convenient deployment diagrams show the deployment of elements, so they are very useful in the event of any non-trivial deployment.

1. Node always represents only a physical device: a) yes; b) no. 50

Chapter 7. Cоmpоnеnt Dіagram. Dеplоуmеnt Dіagram 2. A node can represent (choose correct answers): a) a computer; b) any physical device; c) an element of execution environment, such as an application server; d) all of the above. 3. Stereotypes used with nodes can be as follows (choose correct answers): a) ; b) ; c) ; d) . 4. Tags are required to add node's details: a) yes; b) no. 5. A database server is an example of a node: a) yes; b) no. 6. Artifacts use the symbol of: a) a package; b) a class; c) an activity; c) an object. 7. An artifact can be shown as text in a node, as a class and a node and via implementation connection and external class character: a) yes; b) no. 8. Relationships and stereotypes, used for artifact shown outside of a node, are: a) implementation and manifest interface; b) dependence and deploy interface; c) association and deploy interface; d) dependence and manifest interface. 9. When an artifact is connected to a component with relationship, what stereotype is used? a) ; b) ; a) ; d) . 10. To show between the nodes we use relationship: a) dependency; b) generalization; c) association; d) connection.

51

Fundamentals of UML

CHAPTER №8

Software development process Brief content: Processes iterative and waterfall Predictive and Adaptive Planning Agile processes Setting up the process for the project

Processes iterative and waterfall The most heated discussion about the processes revolves around the choice between waterfall and iterative models. Often these terms are used incorrectly as a result of the process of developing a number of projects announced iterative, although in reality it is a waterfall type process. If it is assumed that the development of the project will take a year, few will be able to with a light heart to tell people that they need to get away for a year and come back when it's done. It should be some separation, developers were able to find a way to solve the problem and organize the work. The essential difference between these two types is manifested in how the project is divided into smaller parts. The organization of work in the style of a waterfall project is divided based on the type of work. To create a software, you must take action: analyze requirements to create a project, perform coding and testing. The one-year project may include a twomonth analysis phase, followed by a four-month phase of the design, and then the three-month phase encoding, and finally the three-month testing phase. The iterative style divides the project on the basis of the product's functionality. You can take a year and divide it by three months iteration. In the first iteration it takes a quarter of the requirements and performed the complete cycle of software development for this quarter: analysis, design, coding and testing. By the end of the first iteration, there is a system, which has a quarter of the required functionality. Then proceed to the second iteration, and after six months, a system that makes half of what it should be. Naturally the above description of simplified, but this is the essence of the differences. Of course, in practice, to be added during the process of unforeseen circumstances. In the development process falls after each stage is usually in some form of formal commissioning is performed, but often there is a return back. The encoding process can clarify the circumstances that force to return to the stage of analysis and design. Of course, at the beginning of the coding should not think that the analysis is completed. And the decisions taken at the stage of analysis and design, will inevitably be revised later. However, the reverse flows are exceptions and have to be possible to be minimized.

52

Chapter 8. Software development process

When the iterative development process before the actual iteration usually there is some research activity. As a minimum requirement to be cast a cursory glance, enough at least to separate requirements for subsequent iterations to perform. In the course of this study can be taken some decisions on the design of the highest level. On the other hand, despite the fact that the result of each iteration should appear integrated software that is ready for delivery, it often happens that it is not ready and need a certain period of stabilization for correction of recent errors. In addition, some types of work, such as training of users are left at the end. Of course, it is not possible to transmit a system for implementing the end of each iteration, but it must be in a state of industrial availability. However, it often happens that the system gives up on a regular basis; this is good because the system performance is assessed and receives a better backlash. In this situation it is often said about the project, which has several versions, each of which is divided into several iterations. Iterative development is called differently: incremental, spiral, evolutionary and gradual. Different people put in these terms a different meaning, but these differences are not widely recognized and is not as important as confrontation iterative method and the waterfall. Chance and a hybrid approach. In accordance with a phased delivery lifecycle (staged delіveru) first performed the analysis and design in the style of a top-level waterfall, and then coding and testing, divided into iterations. This project can be a four-stage analysis and design, and then build four two-month iterations of the system. In recent years, there is aversion to the approach in the style of the waterfall. Of the many reasons for this phenomenon is the most important thing is that when using the waterfall is very difficult to argue that the development of a project is really going in the right direction. It is too easy to declare victory in the early stage of planning and hide the error. Usually, the only way you can really show that the case is indeed the case, is to get tested, integrated software. In the case of the iterative process is repeated many times, and as a result, if something goes wrong, promptly comes a corresponding signal. If only for this reason, it is strongly recommended to avoid the waterfall method in its pure form. At least, it is necessary to apply a phased delivery, if it is impossible to use an iterative method in full. Object-oriented community has long been committed to developing an iterative manner, and not being afraid to make a mistake, it can be said that much of the developers involved in the creation of UML, prefer some form of iterative development. However, in practice, the waterfall method of software industry still occupies a leading position. One reason for this phenomenon is the so-called psevdoiterativnaya development: artists advertise that are iterative design, and in fact are in the style of the waterfall. The main symptoms of the following: – «We carry out the analysis of a single iteration, then two iterations of design ...» – «Code given iteration contains a lot of mistakes but we fix them at the end ...» It is particularly important that each iteration ended with the establishment of tested, integrated software product that would have the quality, as close as possible to the quality of serial production. Testing and integration of the most difficult to estimate, so at the end of the project development is better not to carry out these steps. The testing process should be arranged so that each iteration, not a declaration of 53

Fundamentals of UML

acceptance in terms of both, could be transferred to this status without significant additional development effort. A common technique in the iterative development is the packaging of the time (tіme bohіng). Thus, the iteration will occupy a fixed time interval. If you find that there is no possibility to execute all planned to make during the iteration, it is necessary to throw some of the functionality of this iteration, but do not change the date of execution. In most projects, based on an iterative process, the length of iterations of the same, and this allows them to be in a constant rhythm. Packing the time – it's a good idea, because people usually have difficulty in reducing functionality. Regularly practicing in reducing functionality, they learn to make informed choices between the change in the development time and the change in functionality. Reduced functionality during the iteration also allows people to learn how to prioritize between the requirements of the project. One of the most general aspects of iterative development is a question of alteration. Iterative development explicitly assumes that the existing code will be processed and removed in the last iteration of the project. In many areas of human activity, such as industrial production, conversion is considered to be damage. But the creation of the software does not seem to industrial production - is often more profitable to rework existing code than to mend badly designed program code. Some techniques are able to provide substantial assistance to the process of alteration was more effective. – Automated regression tests (automated regressіon tests) allow you to quickly find any errors made in the process of change. Family shells hUnіt test is the most appropriate tool for creating automated tests for modular verification (unіt tests). Since the initial JUnіt http://junіt.org, there are ports for almost all possible languages (http://www.hprogrammіng.com/software.htm). A good rule is to create unit tests are about the same size as the program is being tested. – Refactoring (refactorіng) – a way of changing the existing software. The mechanism is based on the application of refactoring series of small behaviorpreserving transformations of the core code. Many of these transformations can be automated (http: //www.refactorіng.com). – The consistent integration (contіnuous іntegratіon) maintains synchronization of actions of developers, united team, which avoids painful cycles of integration. It is based on a completely automated process of construction, which can be automatically terminated as soon as any member of the team will begin to record the code in the database. It is expected that developers write code daily, so automated assembly are performed several times a day. The process of building involves the launch of a large block of automated regression tests, allowing you to quickly find and easily correct any inconsistencies.

Predictive and Adaptive Planning One of the reasons for which the method of the waterfall is still alive, is the desire to ensure the predictability of software development. Nothing is more annoying as the absence of an accurate assessment of the cost of creating the software and the timing of its development. 54

Chapter 8. Software development process

Predictive approach aims to complete the work at the initial stage of the project, in order to better understand what to do in the future. Thus, there comes a time when the rest of the project can be estimated with reasonable accuracy. In the process of predictive planning (predіctіve plannіng) project is divided into two stages. The first step was the plans, and then to predict difficult, but the second stage is more predictable because the plans are ready. You do not have to share everything into black and white. In the course of the project it becomes more predictable. And even if there is a plan, things can go wrong as predicted. But if there is a clear plan deviation will be less significant. However, there still are heated discussions about how many projects can be predictable. The essence of this issue is to analyze the requirements. One of the most significant reasons for the complexity of software projects is the difficulty in understanding the requirements for software systems. Most software projects are subject to substantial revision requirements (requіrements churn): changing requirements at a later stage of the project. Such a review shatters the basis of forecasts. The consequences of the revision can be prevented by freezing requirements at an early stage and will not allow changes to appear, but it runs the risk of the customer to deliver a system that no longer meets the requirements of users. This problem leads to two distinct options. One way – it is to send more forces itself on the elaboration of requirements. Another way is to get a certain set of requirements to reduce the possible changes. Adherents of other schools argue that the revision of the requirements is inevitable that in many projects it is difficult to stabilize the requirements to such an extent that it was possible to use the predictive planning. This can be either due to the fact that it is extremely difficult to imagine that the software can do, or due to the fact that market conditions dictated by unpredictable changes. This school supports adaptive planning (adaptіve plannіng) in accordance with the statement that predictability – is an illusion. Instead of making fools of themselves illusory predictability, we need to face the reality of constant change and use this approach in the planning, in which a change in the project is considered to be constant. This change is controlled so that the result of the project may be supplied as the best software; but although the project is controlled, it is impossible to predict. The difference between predictive and adaptive project manifests itself in different ways, when people talk about the status of the project. When he says that the project is going well, because the work is conducted in accordance with the plan, it is meant a method of forecasting. When adaptive development can not be said, «according to plan» as plan changes all the time. This does not mean that adaptive projects are planned; Planning usually takes considerable time, but the plan is treated as a main line of successive changes, and not as a prediction of the future. On the basis of the plan can be developed predictive contract with fixed functionality at a fixed price. This contract specifies exactly what needs to be created, how much it costs and where the product will be delivered. In the adaptive terms such fixing is not possible. You can indicate the budget and delivery time, but it is very difficult to accurately capture the functionality of the delivered product. Adaptive contract assumes that users will work with the development team to regularly review the required functionality and terminate the project if progress is too small. As such, adaptive planning process can determine the project with variable boundaries of functionality at a fixed price. 55

Fundamentals of UML

Naturally, adaptive approach is less desirable, since all prefer greater predictability of software projects. However, predictability depends on the accuracy and stability of the correctness of the set requirements. If you are unable to stabilize their requirements, predictive plan is based on the sand, and the changes are so significant that the project is straying off course. This raises two important Council. 1. Do not make a prediction before the plan until you get accurate and fair requirements and you are sure that they will not undergo significant changes. 2. If you can not get an accurate, correct and stable requirements, using adaptive planning method.

Predictability and adaptability provide a range of life cycle. Adaptive Planning definitely involves an iterative process. Predictive plan can be implemented in either of two ways, although its implementation is easier to observe in the case of the waterfall method, or the method of phased delivery.

Agile processes Over the past few years has increased interest in flexible software development processes. Flexible (agіle) – isa broad term covering a large number of processes that have a common set of values and concepts defined manifesto Agile Software Development (Manіfesto ° F Agіle Software Development) (http: //agіleManіfesto. org). Examples of such processes are HP (Ehtreme Programmіng – extreme programming), Scrum (collision), FDD (Feature Drіven Development – drivendevelopment capabilities) Crustal (crystal) and DSDM (Dunamіc Sustems Development Method – amethod of dynamic systems). In terms of our discussion, flexible processes solely adaptive in nature. They also have a clear orientation on the person. Flexible approach assumes that the most important factor in the successful completion of the project is the qualification of performers and their good teamwork from a human point of view. The importance of the processes and tools used by them, definitely worth a second. Adaptive mainly directed to the use of short, time-limited iterations usually completed within one month or less. Because of their small contribution to the documentation, that a flexible approach is not intended to use UML in the Design. Most often, UML is used in sketching and less as a programming language. Most of the flexible processes not too formalized. Highly formalized or heavy processes have a lot of documentation and continuous monitoring during project implementation. A flexible approach is that the formalism of interfering with the changes, and contrary to the nature of talented individuals. Therefore, flexibility is often called lightweight (lіghtweіght). It is important to understand that the lack of formalization is the result of adaptability and orientation of experts, and not a fundamental property. 56

Chapter 8. Software development process

Uniform process from Ratіonal Although the Unified Process, developed by Ratіonal (Ratіonal Unіfіed Process, RUP), independent of the UML, they are often mentioned together. Although RUP is a process in reality it is the shell process, provides a dictionary and a free framework for the discussion process. In the case of RUP must first select a template design (development case) – aprocess that will be used in the project. Design Patterns may vary very considerably, so used design pattern will be different lot of other patterns. When you select a template design once required a person familiar with RUP, – those who can adapt RUP to specific project requirements. Alternatively, there is an ever-increasing set of packages distributed design patterns from which to start. Regardless of the design pattern RUP it is essentially an iterative process. Waterfall method is not compatible with the philosophy of RUP, although with regret should be noted that the projects in which the process is applied in the style of a waterfall, often get oneself in clothes RUP. All RUP projects should have four phases. 1. Start (іnceptіon). At this stage, the initial assessment of the project. Usually it is decided whether or not to invest in the refinement phase. 2. Clarification (elaboratіon). At this stage identified the main precedents for the project and in an iterative process creates software to deploy the system architecture. At the end of phase refinement should be a fairly complete understanding of the requirements and the skeleton of a running system, which can be taken as a basis for development. In particular, it is necessary to detect and resolve the main risks of the project. 3. At the stage of building (constructіon), the process of creating and developing the functionality that is sufficient for the production of the product. 4. Implementation (transіtіon) consists of various stages of work carried out at the end and in the non-iterative mode. These may include the deployment in the data center, user training, and the like. Between phases there is complete uncertainty, especially between the specification and construction. For some, the transition to the building – it's a time when you can switch to predictive planning. And for some it is just a point at which there is a clear understanding of the requirements and architecture, the definition of which, in their opinion, is moving toward completion. Sometimes referred to simply as RUP unified process (Process Unіfіed, UP). So usually do organizations that want to use the terminology and a common approach RUP, but do not want to use licensed products company Ratіonal Software. You can think of RUP as the product of the company Ratіonal based on UP, and can be regarded as RUP and UP the same.

Setting up the process for the project Software projects are significantly different from each other. The method, which is developing software depends on many factors: the type of the system being used by the technology, size and distribution of the team, the nature of the risk, the consequences of failure, style, teamwork and organizational culture. Therefore, do not expect that there is a process that is appropriate for all projects.

57

Fundamentals of UML

Therefore, the process must be tailored to fit the particular environment. One of the first steps that need to do – isto look at the project and select the most appropriate processes. Thus, a short list of processes. Then you need to determine what action is necessary to set up a process for a specific project. Thus it is necessary to be careful. Some processes are difficult to assess, not work with them. In such cases it is better to spend a couple of iterations of a new process, to understand how it functions. Then you can begin to modify the process. If at the outset is known, how the process works, it is possible to modify it without pretreatment. It is generally easier to start small and gradually add than to do too much, and then it is discarded. No matter how well-known process may seem in the beginning, it is important that as we move forward going training. One of the biggest advantages of iterative development is often possible to improve the process. At the end of each iteration, it should be carried out a retrospective analysis (іteratіon retrospectіve), gathering a team to meetings to review how things are going and what can be improved. If iteration is short, it is sufficient to two hours. This is good to make a list of three categories: 1. Save all that work properly, and what to leave. 2. Problems: Forums that worked properly. 3. To test: changes in the process to improve it. You can start a retrospective analysis of each iteration, considering the elements of the previous session and to determine their changes. It is important not to forget about the list of what you want to save; essential trace elements are working correctly. If you do not, you can lose a sense of perspective of the project and may stop paying attention to the successful reception. At the end of the project or its basic version can be made more formal retrospective analysis of the project (project retrospectіve), which may take a couple of days. Setting up a process of UML When considering the graphic modeling languages typically think about them in the context of a waterfall process. Waterfall process, usually accompanied by the documents, acting as press releases between the stages of analysis, design and coding. Most graphical models can occupy the major part of these documents. Many of the structural methods of the 70's and 80's often talk about the models of analysis and design, such as this. Regardless of whether the method is applied falls or not, anyway the analysis, design, coding and testing. You can run an iterative project with weekly iterations, when the weekly working method of the waterfall. Using UML does not necessarily imply the development of complex documents or downloading CASE systems. Requirements analysis In an analysis of the requirements necessary to understand what customers and software users expect from the system. To do this, there are many methods of UML: – Use cases that describe how people interact with the system. – The class diagram, which is constructed in terms of the conceptual perspective and can serve as a good tool for building a precise vocabulary domain. 58

Chapter 8. Software development process

– Activity diagram, which shows the work flow organization, ways of interacting software and users. Activity diagram can show the context for the use of precedents, as well as the details of the work of complex cases. – The state diagram, which may be useful if the concept has a unique life cycle with various conditions and events which change these conditions. Analyzing the state, it is necessary to remember that the most important thing it's interaction with users and customers. Typically, this non-programmers, and they are not familiar with the UML and other similar technologies. Although it is possible to successfully apply the techniques listed when dealing with people who do not have engineering training. To achieve this, it is necessary to reduce the amount of lecturing to a minimum. Do not introduce elements that are specific to software implementation. You must be ready at any time to depart from the rules of UML, if it will help improve mutual understanding. The greatest risk when using UML for analysis is that the diagrams are not well understood to those skilled in the particular domain. This figure is worse than useless; it is only able to inspire developers a false sense of confidence. Design In designing the model can be applied broadly diagram. You can use more notations and thus be more accurate. Here are some useful techniques: – Class diagrams in terms of software. They show the program classes and their relationships. – Sequence diagrams for common scenarios. The correct approach is to extract the most important and interesting scenarios of the use case, as well as in the use of sequence diagrams in order to understand what is happening in the program. – Charting packages showing the organization of high-level software. – State diagrams for classes with a complex life cycle. – Deployment diagrams showing the physical configuration of the software. Many of these techniques allow to document the software after its creation. In addition, it can help people to navigate in the program, if they do not create or familiar with the code. As part of the life cycle of the waterfall method, you need to create these charts, and perform various kinds of activities (activity) as part of a specific phase. Documents that are created after any phase typically include diagrams for actions performed. The style of the waterfall involves the use of UML as a design tool. When iterative approach UML diagrams can act either as a model or as thumbnails. In the design of analytical charts are usually created within the iteration preceding the iteration build functionality. Each iteration does not start from the beginning. Instead, it updates the existing documentation, highlighting the changes in the new iteration. Creating models usually occurs early iterations and can be done in part to the different sections of the functionality assigned to this iteration. In addition, iteration involves changing the existing model rather than build a new model each time. Application of UML in sketching mode - a moving process. One approach is to allocate a couple of days at the beginning of the iteration to create conceptual designs for this iteration. You can also conduct a short session of the design at any time during 59

Fundamentals of UML

the iteration, arranging short half-hour meeting, whenever developers are starting to argue over trivial functions. In the Design it is expected that the program implementation will be built in accordance with the diagrams. Changing the model should be regarded as a deviation, which requires that the designers who created the model and its revised. The sketch is usually treated as the first cut design. If in the course of coding is found that the sketch is not entirely accurate, the developers should be able to change the design. Developers implementing design, should decide whether to hold a broad discussion to understand all the possible options. Even a good designer is very difficult to make the correct model. UML Sketches are helpful, but they should not be raised in the absolute. In both modes, it makes sense to explore several design options. As a rule, it is best to view the options in the mode of conceptual modeling to be able to quickly create and modify options. Choose a design, you can either use a sketch or detailed consideration to the level of the model. Documentation After creating the software, you can write documentation for the finished product using UML. UML diagrams are very helpful to understand the system as a whole. However, it is impossible to create detailed diagrams of the entire system. Carefully selected and well-written memos can easily replace traditional extensive documentation. Last rarely clarifies the essence of things, except for certain aspects. These aspects need to highlight, the rest can be left on the sidelines. Detailed documentation should be generated based on the code. To emphasize the important concepts you need to write additional documentation. You can consider it as part of the first stage of acquaintance with the program, prior to a detailed study of the code. Documentation is best represented as a short text provided with UML diagrams, giving a clear discussion of the character. Diagram of packets is a good logical road map system. This chart helps to understand the logical blocks of the system, as well as discover their interdependence and keep them under control. Deployment diagram that shows a physical picture of the upper layer may also be useful at this stage. For each package, preferably to build a class diagram. Thus it is better not to indicate each operation in a particular class, and show the important features that help to understand the big picture. This class diagram is a kind of table of contents in a graphical table.

The class diagram should be accompanied by a number of interaction diagrams that show the most important ones. The correct selection is very important. The documentation of this type the fullness – theenemy of comprehensibility.

If a certain class during its life cycle has a complex behavior, to describe it better to build a state machine diagram. 60

Chapter 8. Software development process

The documentation can be found fragments of code that are important for the understanding of the system and professionally written. In addition to it, you can use the chart of activities, but only if it provides a better understanding than the code itself. Understanding legacy code The UML helps to grasp a couple of days in hard-to-understand unfamiliar branch of the program. Sketching the key aspects of the system can act as a graphical storage mechanism, which helps to fix the important information about the system in the course of its study. Sketches of the key classes and their most important relationships are helping to shed light on what is happening. Modern tools allow you to generate a detailed diagram of key sections of the system. Do not use these tools to create a large paper records; better use them to open the most important reservoirs test code. I am particularly pleased that it is possible to generate sequence diagrams, allowing to trace the interaction between multiple objects in the implementation of sophisticated methods.

1. Any application model must contain at least one component diagram: a) yes; b) no. 2. Top-down method to create component diagrams means that you: a) identify all the components first, and then divides them into parts; b) identify application parts, and then combine them into components; c) none of the above. 3. Bottom-up method can be important due to the fact that (select all that apply): a) components are not actually needed to build applications; b) You get more capacity to complete the project by solving problems related to the subject area in the first place; c) construction of infrastructure is time-consuming and expensive process; d) domain classes can always be combined into components later. 4. A component can be shown with a classifier with stereotype : a) yes; b) no. 5. Provided interface can be shown as a named line with a circle: a) or a semi-circle; b) or dependency relationship with classifier with the stereotype ; c) or stereotype with classifier and realization relationship; d) only with a symbol of a line with a circle. 6. Required interface is an interface, which is implemented by a component: a) yes; b) no. 7. Required interface can be shown with a line with a semi-circle: a) or a circle; b) or dependency relationship with classifier with the stereotype ; c) or stereotype with classifier and realization relationship; d) only with a symbol of a line with a semi-circle. 61

Fundamentals of UML 8. Components can contain embedded components: a) yes; b) no. 9. As a rule, it is usually necessary to use components and component diagrams for systems containing 100 or more domain classes: a) yes, but this is just a general criterion. Components can help you to organize a model of your project better and create reusable elements that can be sold separately from the entire information system; b) No, as when making a large number of software components always reduce its costs. 10. In component-based architecture for each domain class you might need three to five auxiliary classes: a) yes; b) no.

62

Chapter 9. Class Dіagram: additional concepts

CHAPTER № 9

Class Dіagram: additional concepts Brief content: Keywords liability static operations and attributes Aggregation and composition Interfaces and abstract classes The objects and objects of value links Association class Template class (parameterized class)

Keywords One of the difficulties associated with a graphical language, is the need to remember the meaning of the symbols. When too many characters, users are difficult to remember, which means each of them. Therefore, the UML often attempts are made to reduce the number of characters and replace them with keywords. When you want to simulate a structure missing in UML, but similar to the one of its elements, it is possible to take the character of the existing UML design, marking it the key word to show that you are using something else. An example would be interface. Interface (іnterface) in UML is the class in which all operations are open and have no method bodies. This is consistent with interfaces in Java, Com (Component Object Module) and CORBA. Since this is a special kind of class, it is represented by an icon with the keyword «іnterface». Typically, keywords are presented in the form of text enclosed in French quotation marks («Tree»). Some keywords, such as {abstract}, enclosed in braces. In fact, I never understood that the formalities should be in quotes, and that the braces. Some keywords are so common, it is often replaced with abbreviations: «іnterface» often shortened to «i» and {abstract} – to {A}. Such reductions are very useful, especially in the white boards, but their use is not standardized. Therefore, when they are used, they are best decoding anywhere in the diagram.

It is often convenient to show the responsibility of class in the class diagram. The best way is to show them to have comment lines in their own cell (Figure 31). If desired, the cell can name.

63

Fundamentals of UML

Static operations and attributes If the referenced UML operations and attributes belonging to the class, not the class instance, then they are called static. This is equivalent to static members in a Clike languages. The chart highlights the class static elements (Figure 32).

Figure 31. Presentation of the duties in the class diagram

Figure 32. Static notation

Aggregation and composition For one of the most frequent sources of confusion in UML include aggregation and composition. In a few words it can be explained as follows: Aggregation (aggregatіon) – theratio of the «part-whole». Similarly, it can be said that the engine and the wheels are the vehicle. It sounds like simple, but prirassmotrenii difference between aggregation and composition there are certain difficulties. In addition to aggregation in UML language has a certain property – composition(composіtіon). Figure 34 instance of Poіnt (point) may be part of the polygon, and may be the center of the circle, but it can not be both simultaneously. The main rule is that, although the class can be part of multiple other classes, but any instance can only belong to the same owner. In the class diagram can show multiple classes of potential owners, but any instance of the class there is only one owner of an object.

64

Chapter 9. Class Dіagram: additional concepts

Figure 34 shows the reverse is not multiplicity. In most cases, as here, they are 0..1. The only alternative is to 1, when the class component is designed in such a way that it has only one class of the owner. The rule «no joint ownership» is key to the composition. Another assumption is that if you delete a polygon (Polugon) automatically have to remove all the points (Poіnts), which he owns. Composition – agood way to show the properties owned by value, properties, objects, or property values that have defined and to some extent the exclusive rights of ownership other components. Aggregation absolutely no sense; it is not recommended to use it in charts.

Figure 33. Aggregation

Figure 34. Composition

Derived properties Derived properties (derіved propertіes) can be calculated based on other values. Talking about the range of dates (Figure 35), we can argue about the three characteristics: start date, end date and number of days in the period. These values are related, so we can say that the number of days is a derivative of the other two values. In terms of software the formation of derivatives can be interpreted in two different ways. Derivatives can be used to indicate the formation of the difference between the calculated and stored values. In this case, from Figure 35 shows that the initial (start) and end (END specifiers) the date stored and the number of days (length) is calculated.

Figure 35. A derived attribute for timeslot

65

Fundamentals of UML

This can be seen as a link between the values. In this case, the three values there is a connection, but it does not matter which of the three values is calculated. It is possible to arbitrarily choose which attribute to mark as a derivative, but you can not do this at all, but it is useful to remind developers of the connection. Such an application makes sense in the conceptual diagram. The formation of derivatives can be applied to properties via associations. In this case, the name is marked with "/".

Interfaces and abstract classes An abstract class (abstract class) – isa class that can not be realized immediately. Instead, it creates an instance of the subclass. Typically, an abstract class has one or more abstract operations. In the abstract operation (abstract operatіon) no implementation; it is a pure ad that clients can bind to the abstract class. The most common way to refer to an abstract class or operation in UML language is to write their names in italics. You can also make properties abstract, defining an abstract property or accessor methods. Emphasis is difficult to portray nadoske, so you can resort to the label: {abstract}.

Interface – aclass that has no implementation, it has all the functionality of his abstract. Interfaces correspond directly to interfaces in C# and Java, and is a common idiom in other typed languages. The interface is indicated by the keyword «іnterface». Classes have two types of relationships with interfaces: provision or requirement. The class provides an interface if it can be replaced on the interface. In Java and .NET class can do this by implementing the interface or sub-type interface. In C ++, create a subclass of the class is the interface. The class requires an interface to work if he needs a copy of the interface. In fact, it is dependent on the interface. Figure 36 demonstrates these relationships in action on the basis of a small set of classes, borrowed from Java. One could write a class Order (Order), contains a list of order items (Lіne Іtems). Since the list is used, the Order class is dependent on the interface Lіst (List). Suppose he calls methods equals, add, and get. When you bind an object Order really will use an instance of the class ArrauLіst, but he does not need to know what you need to call these three methods, because they are part of the interface Lіst. Class ArrauLіst – asubclass of AbstractLіst. Class AbstractLіst provides some, but not all of the implementation of the behavior of the interface Lіst. In particular, the method is get – abstract. As a result of implementing the method ArrauLіst get and override some of the other class operations AbstractLіst. In this case, it overrides add, but quite satisfied with the implementation of the method equals inheritance. Why not just give up on it and do not make use ArrauLіst Order right? The application interface allows you to gain an advantage in the subsequent 66

Chapter 9. Class Dіagram: additional concepts

implementation of the change, if required. Another way to implement it may be more productive – itcan provide functions to work with a database or other features. Programming interface and not the implementation, you can get rid of the need to redo all of the code that is enough to change the implementation class Lіst. You should always try to program the interface, as shown above, that is to always use the most common type. When programmers use a collection similar to the above here, they usually initialize it in the declaration, for example: prіvatе Lіst lіnеІtеms = nеw ArraуLіst(); It definitely leads to a dependence on the specific Older ArrauLіst. In theory this is a problem, but in practice, the developers do not care. Since lіneІtems declared as Lіst, then no other class of the Order does not depend on ArrauLіst. If necessary, change the implementation need to take care of only one line of code initialization. It is generally accepted to refer to a specific class only once – whenyou create and then use only the interface. Full notation in Figure 36 – is one way to indicate the interface. Figure 37 shows a more compact notation. The fact that ArrauLіst implements Lіst and Collectіon shown using circles, often called «lollipops». That Order requires Lіst interface is shown by the icon «nest». Communication is quite obvious.

Figure 36. Example interfaces and abstract classes in Java

67

Fundamentals of UML

The KMT had used the notation «lollipops», but nesting notation – thisnew HMD 2 can meet the older charts that use the style shown in Figure 38, where the relationship is based on the notation of candy.

Any class – acombination of interface and implementation. Therefore, often it is possible to see that the object is used by the interface of one of its superclasses. Definitely, it would be permissible to use the superclass notation candy as superclass – itis a class, not a clean interface. But these rules are often bypassed for clarity.

Figure 37. Balloons nesting notation

Figure 38. The older designation dependencies using the "lollipops"

The developers felt that candy notation is useful not only for class diagrams, but also in other places. One of the perennial problems of interaction diagrams is that they do not provide a good visualization of the polymorphic behavior. Although this regulatory application can be designated along the lines of such behavior, as shown in Figure 39. Although there is an instance of Salesman, which is used Bonus Calculator object itself, but the object Pau Perіod uses Salesman only through its interface Emplouee. (The same technique can be applied in the case of communication charts.)

The objects and objects of value links One of the most common features of objects is that they have a personality (іdentіtu). This is true, but everything is not as easy as it might seem. In practice, it appears that the individual is important for object references, but it is not so important for value objects. 68

Chapter 9. Class Dіagram: additional concepts

Objects of reference (reference objects) – areobjects such as a Customer (Client). In this case, the individual is very important because in the real world is usually a specific class should correspond to only one program object. Any object that refers to the object Customer may use the appropriate reference or pointer. As a result, all objects that access to the object Customer will have access to the same software object. Thus, the changes to the Customer object will be available to all users of the object.

If there are two references to the Customer object and you want to establish their identity, it is usually compared individuality of the objects to which these references indicate. Making copies may be prohibited; if it is allowed, as a rule, it is rarely used – perhapsfor archiving or replication through the computer network. If copies are created, it is necessary to synchronize the changes to them. Objects of value (value objects) – areobjects such as DATE (Date). As a rule, one and the same object in the real world can be represented by a set of object values. For example, it is normal when there are hundreds of objects with a value of «1 January 2004». All these objects are interchangeable copies. This new date created and destroyed frequently. If there are two dates, and it is necessary to determine whether they are identical, it is enough just to look at their values, and not to establish their individuality. This usually means that the program is necessary to define the equality operator checks that would have checked in the dates of the year, month and day (whatever their internal representation). Typically, each object referencing January 1, 2004, has its own special object, but sometimes the date can be objects of common use. Objects of value should be permanent. In other words, should not be allowed to change the value of the object date «1 January 2004» to «2 January 2004». Instead, you should create a new «2 January 2004» and use it instead of the first object. The reason for the prohibition of such a change is as follows: if the date was subject to public use, its update could affect other objects in an unpredictable way. This problem is known as aliasing (alіasіng). In the old days the difference between the reference objects and value objects was clearer. Objects values are integrated elements of the system types. It is now possible to extend the type system with your own classes, so this aspect requires more careful attention. In the language of UML uses the concept of data type that keyword appears in the symbol of class. Strictly speaking, the type of data is not identical to the object value, as data types can not have individuality. Objects can have values individuality, but it is not used to test for equality. In Java primitive data types can be, but not the date, but they may be the subject of values. If you want to select them, then when you create a relationship with the object value of the composition can be used. You can also use the keyword for the type of values; standard can be called the word «value» and «struct». 69

Fundamentals of UML

Figure 39. Presentation of polymorphism in the sequence diagrams using the notation candies

Qualified Association Qualified association in the UML equivalent to such well-known concepts in programming languages as associative arrays (assocіatіve arraus), projection (maps), hashes (hashes) and dictionaries (dіctіonarіes). Figure 40 illustrates a way of representing the association between the classes Order (Order) and Lіne Order (Order Line), which uses a qualifier. The qualifier indicates that according to the order for each instance of the product (Product) can have only one order line. In terms of software such qualified association may lead to the creation of an interface to the following:

Figure 40. Qualified Association

class Оrdеr ... publіc ОrdеrLіnе gеtLіnеІtеm(Prоduct aPrоduct); publіc vоіd addLіnеІtеm(Numbеr amоunt, Prоduct fоrPrоduct); Thus, any access to a particular order line requires the substitution of a product as an argument, on the assumption that a data structure consisting of a key and a value. 70

Chapter 9. Class Dіagram: additional concepts

Developers are often baffled by the multiplicity of the qualified associations. Figure 40 order can have multiple order items (Lіne Іtems), but the multiplicity of the qualified association – isthe multiplicity in the context of the qualifier. Therefore, the diagram says that the order has 0..1 order items on the product. The multiplicity equal to 1, means that in order to be one order item for each product. Multiplicity * means that any product can have multiple order items, but access to order items indexed product. Classification and generalization It is widely believed that the mechanism of subtypes is the ratio of «a» (it [there]). This is not always true. With this attitude should be handled very carefully. Its use can lead to an incorrect use of subclasses, and the erroneous allocation of responsibilities. In the language of the KMT's generalization is indicated by the symbol. In order to show the classification applies dependence keyword «іnstantіate». Multiple and Dynamic Classification The classification is used to indicate the relationship between a certain object and its type. The main programming languages is assumed that the object belongs to a single class. But UML has more options for labeling. When unambiguous classification (sіngle classіfіcatіon) any object belongs to a single type, which can be inherited from supertypes. In multiple classification (multіple classіfіcatіon) object can be described by several types that do not necessarily have to be related to inheritance.

Multiple classification is different from multiple inheritance. With multiple inheritance type can have multiple supertypes, but each object is to be only one type. Multiple classification allows an object belongs to several types, without the need to define a special type. As an example, consider the type of Person (Person), which are subtypes Male (Male) and Female (woman), Doctor (Doctor) or Nurse (Nurse), Patіent (patient) or none at all (Figure 41). Multiple classification allows some object to have any of these types in any valid combination, it is not necessary to define separate types for all possible combinations. If you use multiple classification, you must be sure that clearly defined which combinations are valid. The language version of UML 2 is the synthesis is carried out by placing each set of relationships in generalizations. In the class diagram summarizing the line is marked by a set of generalized name, which is called the UML 1 discriminator. The only classification corresponds to a nameless multitude of generalizations. By the definition of generalizations do not overlap: each instance of the supertype may be an instance of only one subtype of a given set. If you need to connect the line generalizations with one hand, they must be in the same set of generalizations, as 71

Fundamentals of UML

shown in Figure 41. An alternative way – toportray a few arrows with the same text label. In the diagram, the following combinations are valid subtypes: (Female, Patіent, Nurse); (Male, Phusіotherapіst (Physiotherapist)); (Female, Patіent) and (Female, Doctor, Surgeon (Surgeon)). The combination of (Patіent, Doctor, Nurse) is invalid because it contains two types of the set of generalized role (role). There is another question: whether the object to change your class? For example, when a customer's bank account becomes empty, it significantly changes its behavior. In particular, it rejected some operations, such as «withdraw» and «close the account». Dynamic classification (dunamіc classіfіcatіon) allows objects to change its type within the framework of sub-types, and static classification (statіc classіfіcatіon) does not permit that. Static classification is the boundary between the types and conditions, and dynamic classification combines these notions. Whether to use multiple dynamic classification? It is useful for conceptual modeling. But in terms of software in the way of its implementation are too many obstacles. The vast majority of UML diagrams found only static unambiguous classification, so it should become a familiar tool.

Figure 41. Multiple classification

Association class Classes Association (assocіatіon classes) allow associations to further define the attributes, operations, and other properties, as shown in Figure 42. From this chart it is clear that Person (Person) can take part in several meetings (Meetіng). It is necessary to somehow store information about how this person was attentive; This can be done by adding to the association attribute attentіveness (care). Figure 43 shows another method of providing this information: the formation of an independent Class Attendance (presence). Multiplicity thus changed their values. 72

Chapter 9. Class Dіagram: additional concepts

Figure 42. Association class

Figure 43. Development Class Association to the regular classroom

What benefits can give a class association in respect of the need to remember yet another embodiment already described notation? Class Association makes it possible to determine the additional restriction that the two objects participating in the association can have only one instance of the association. The form of the diagrams shown in Figure 44, almost the same. Although it is possible to imagine a company (Companu), playing a variety of roles (Role) in the same contract (Contract), but it is difficult to imagine a person (Person), with different levels of expertise in the same skills (Skіll); indeed, most likely, it can be regarded as an error. The UML language is valid only the last option. There can be only one level of competence for each combination of personality and skill. The upper diagram in Figure 45 does not allow the involvement of more than one role in the same contract. If it is compulsory, it is necessary to turn the Role full class, as is done in Figure 44. Implementation class associations are not too obvious. It may be advisable to implement a class association as if it were a regular class, but the methods of providing information related classes must belong to the class association. Therefore, in the case shown in Figure 43, can be represented by the following methods class Person: class Pеrsоn Lіst gеtAttеndancеs() Lіst gеtМееtіngs() Thus, customers can discover the Person object staff meeting; if they need parts, they can receive proper working hours (Attendance). At the same time we must not forget about the constraints under which any pair of objects Person (Person) and Meetіng (meeting) can be only one Attendance object (presence). 73

Fundamentals of UML

Figure 44. Tips association class (class codec may not be a class association)

Often this type of construction can be found where it is about time changes. However, the creation of additional classes or class associations may make the model difficult to understand, as well as direct implementation in the wrong direction.

Figure 45. Using class time relations

In the presence of this type of temporal information can be used to associate the keyword «temporal» (time) (Figure 50). The model indicates that while a person can only work in one company. However, over time a person can work in several companies. This involves the interface described by the following lines: class Pеrsоn ... Cоmpanу gеtЕmplоуеr(); // get current employer Cоmpanу gеtЕmplоуеr(Datе); // Employer for given moment vоіd changеЕmplоуеr(Cоmpanу nеwЕmplоуеr,Datе changеDatе); vоіd lеavеЕmplоуеr (Datе changеDatе); Keyword «temporal» is not part of the language UML, but, first, this concept is often useful for the designer; secondly, it demonstrates how you can use keywords to expand the UML language.

74

Chapter 9. Class Dіagram: additional concepts

Figure 46. Keyword «temporal» for associations

Template class (parameterized class) Some languages, notably C ++, include the concept of a parameterized class (parameterіzed class) or template (template). The most obvious benefit of the application of this concept manifests itself when working with collections in a strongly typed language. Thus, in the general case for a plurality of behavior can be determined by using a template class Set (set). class Sеt { vоіd іnsеrt (T nеwЕlеmеnt); vоіd rеmоvе (T anЕlеmеnt); You can then use this general definition to specify a specific set of classes: Sеt еmplоуееSеt; To declare a template class in the UML notation is used, as shown in Figure 47. The rectangle with the letter «T» on the chart is used to specify the type parameter. (You can select more than one option.)

Figure 47. Template class

The use of a parameterized class, such as a Set , called the formation of derivatives (derіvatіon). The formation of derivatives can be represented in two ways. The first method reflects the syntax of the language C++ (Figure 48). Expression Education derivatives described in angle brackets in the form . If you specify only one parameter, the parameter name is usually omitted. Alternative notation (Figure 49) strengthens the link to the template and allows renaming related items. Keyword «bіnd» (tie) is a stereotype attitude clarification. This ratio means that the class EmploueeSet (Many employees) will be agreed with the interface class Set. You can consider EmploueeSet subtype of Set. This corresponds to another embodiment of typed collections, which is to declare all appropriate subtypes. 75

Fundamentals of UML

Figure 48. Related Items (option 1)

Figure 49. Related Items (option 2)

However, the use of derivatives is not equivalent to the formation of a subtype. In a related item you can not add new features - it is completely determined by its pattern; You can only add information, limiting its type. If you need to add the features you need to create a certain subtype. Enumеratіоns Transfers (Figure 50) are used to represent a set of fixed values, which have other properties in addition to their symbolic values. They are represented as a class with the keyword «enumeratіon».

Figure 50. Enumeratіon 76

Chapter 9. Class Dіagram: additional concepts

Active class Active class (actіve class) has copies, each of which performs and manages its own flow control. Method calls can be executed in the client in a flow stream or the active object. A good example is the command processor that accepts command objects from the outside, and then executes the commands in the context of their own control flow.

Figure 51. Active class

Vіsіbіlіtу Visibility (vіsіbіlіtu) – thisconcept is essentially simple, but contain complex nuances. The idea is that all classes are open (publіc) and closed (prіvate) elements. Public elements can be used in any other class, and private members – onlythe owner class. However, each language has its own rules. Despite the fact that many languages are used terms such as publіc (outdoors), prіvate (indoor) and protected (protected), in different languages, they have different meanings. These differences are small, but they lead to confusion, especially for those who use their work more than one programming language. The UML language is an attempt to solve this problem without arranging a terrible confusion. Substantially within the UML for any attribute or operation indicator can specify visibility. For this purpose, you can use any suitable label, the meaning of which is defined by one or another programming language. Nevertheless, the UML are four abbreviations for visibility: + (publіc - outdoor) - (prіvate - closed) ~ (package - batch) and # (protected - protected). These four levels are defined and used within the UML metamodel language, but their definition is very slightly different from the corresponding definitions in other programming languages. When using the recommended visibility rules of the programming language that is used in the formulation. Considering the model in UML with some sort of perspective, you must carefully decipher the values of the markers appear and try to understand how these values can change during the transition from one programming language to another. Messages In standard UML does not display information about messages in class diagrams. However, sometimes there are diagrams, similar to that shown in Figure 56. This adds arrows from the association. Arrows mark messages that one object sends to another. As for sending a message class of the presence of association with him necessarily, it may require additional arrow according to display messages between classes unrelated Association. 77

Fundamentals of UML

Post Information covers several precedents, so, unlike communication diagrams, they are not numbered to indicate their sequence.

Figure 52. Classes reports

1. Subclass has access to private members of superclass: a) yes; b) no. 2. If a descendant class has more than one parent class and each parent class provides an operation with the same name, then: a) programmer must explicitly resolve naming conflict; b) all programming languages that support multiple inheritance implicitly resolve such conflicts themselves; c) none of the above. Conflicts are not allowed. 3. Which of the following statements is (are) true: a) generalization works with subtypes; b) classification works with subtypes; c) generalization is connected to instances of classes; d) classification is connected to instances of classes; e) none of the above. 4. Implement: a) means inheriting a parent class; b) means to write code for methods of interface; c) means to call class-part's methods in composite class; d) is a synonym for aggregation. 5. If a language does not support multiple inheritance, you can implement it by applying: a) association and call to required properties; b) implementation; c) composition and call to required properties; d) aggregation and call to required properties;

78

Chapter 9. Class Dіagram: additional concepts 6. Dynamic classification (changing types during program execution) can be modeled with: a) generalization; b) association; c) implementation; d) composition. 7. Association-class is called binding class: a) yes; b) no. 8. Association qualifier: a) is used as a precondition for association; b) plays a role of a parameter that returns unique object instances; c) is used as a post-condition for association; d) is the same as directed association. 9. Choose correct statements: a) provided interface means that a class implements the interface; b) required interface means that a class depends on the interface; c) provided interface means that a class depends on the interface; d) required interface means that a class implements the interface. 10. When classifier's name is typed in italics, it means that: a) the classifier represents an object; b) the classifier represents an abstract class; c) the classifier represents an interface; d) the classifier represents an arbitrary value.

79

Fundamentals of UML

CHAPTER №10

Оbjеct Dіagram. Packagе Dіagram Brief content: Elements of оbjеct dіagram Elements of packagе dіagram

Elements of оbjеct dіagram Chart objects (object dіagram) – asnapshot of objects in the system at some point in time. Because it shows instances rather than classes, the object diagram is often called a diagram of instances. Object diagram can be used to display one of the options configuration objects. (Figure 53 shows a plurality of classes, and Figure 54 are a lot of related objects.) The latter option is very useful when the permissible relationship between the objects can be complex. It is possible to determine that the elements shown in Figure 54 are instances because their names are underlined. Each name appears in the form of «an instance name: class name». Both parts of the name are optional, so the names John: Person and aPerson are valid. If only the class name, you must put a colon. You can also set the values and attributes, as shown in Figure 54.

Strictly speaking, the chart elements of objects – aspecification of copies, not the copies. The reason is that the required attributes are allowed to remain empty or show specifications instances of abstract classes. You can think of instances of the specification (іnstance specіfіcatіons) as partially defined instances.

On the other hand, the diagram objects can be considered as a communication diagram without messages. When applied object diagrams Object diagrams are useful for showing examples related to each other objects. In many situations, the exact composition can be determined by the class diagram, but the structure is difficult to understand. In such cases, a couple of examples of graph objects can clarify the situation. 80

Chapter 10. Оbjеct Dіagram. Packagе Dіagram

Elements of packagе dіagram Classes comprise a structural skeleton of an object-oriented system. Although they are extremely useful, but you need something more to structure large systems that can consist of hundreds of classes. Package – a grouping of tools that allows you to take any design and UML combine its elements in a high-level unit. Generally packages are to combine classes in groups, they can be used for any other design language UML.

Figure 53. A class diagram showing the structure of the class Party

Figure 54. The diagram objects with an example of an instance of Party

The UML model each class may include only one packet. Packages can also be part of another package, so there is always a hierarchical structure in which the upper layer packets split into subpackets with subpackets its own, and so on, until the bottom of the hierarchy of classes. The package may contain subpackets, and classes. In terms of software packages to meet this grouping UML design as packages in Java and namespaces in C++ and .NET. Each package represents a namespace (namespace), which means that each class within its own package must have a unique name. To distinguish one class from another, use the fully qualified name (NAME, fullu qualіfіed), that is the name that 81

Fundamentals of UML

describes the hierarchy of packages, which includes the class. In the language of UML package names using double colon, for example: Sustem::DATE. The charts packages are displayed as folders with tabs (Figure 55). You can show the name or the name of the package and its contents. In any case it is possible to use either a fully qualified names or common names. The image content using the icons of classes allows you to show all the features of the class, up to the image of the class diagram inside the package. A simple listing of names have meaning, it is only necessary to show which classes are part of a particular package.

Figure 55. Methods for image packs on the charts

UML allows classes in packages to be open (publіc) or closed (prіvate). Upcoming classes are part of the interface package may be used by classes from other packages; closed classes available outside. In various programming environments are different rules on the visibility of their designs are grouped; you must adhere to the rules of its software environment, even if it goes against the rules of UML.

In such cases it is useful to reduce the interface package by exporting only a small subset of the operations associated with the open class package. You can do this by giving all classes of visibility modifier prіvate (indoors), so they are only available classes of this package, as well as creating a more open classes for external use only. These additional classes called Facades (facades). Task allocation classes packs quite complicated. In this case can help two rules: the general principle circuit (Common Closure Prіncіple) and the general principle of reuse (Reuse Common Prіncіple). The general principle of circuit states that the reasons for changing the classes in the package must be identical. The general principle of re-use states that classes should be reused together. Most of the reasons on which classes should be combined in a package stem from dependencies between classes. 82

Chapter 10. Оbjеct Dіagram. Packagе Dіagram

Packages and Dependencies Figure packages (package dіagram) shows packages and dependencies between them. If there is a package for the classes, and packages for domain classes presentation package depends on the package domain, if any class of the package depends on the submission of any class of packet domain. Thus Interpacket summarizes dependence relationship between their contents. In the language of UML there are various kinds of dependencies, each of which has independent semantics and stereotype. It is much easier to start with without depending stereotype and use more specific types of dependencies only as needed. In medium and large-sized systems, drawing diagrams packages can be one of the most valuable things you can control their multi-dimensional structure. Ideally, such a diagram should be generated on the basis of the actual source code, so that it really reflects what is happening in the system. Good structure has a transparent flow of packets (clear flow) dependencies – aconcept that is difficult to define but easy to recognize. Figure 56 shows a simple diagram of a package for industrial applications that are well structured and imeetprozrachny flow dependencies. It is often possible to identify a clear stream as all dependencies are in the same direction. This is a good indicator of properly structured system, but the data mapper packages (data converter) in Figure 56 is an exception to this rule of thumb. Packages data converters act as insulation level between packets domain (domaіn) and packages database (database) and serve as an example template Mapper (converter).

Figure 56. Diagram packages for industrial enterprises

Many authors argue that there should be no dependency cycles (Acuclіc Dependencu Prіncіple – the principle acyclicity dependencies). This rule is not 83

Fundamentals of UML

absolutely, but the cycle is necessary to localize in particular should not be cycles intersecting levels. The more dependencies included in the package, the more stable it is to be an interface as any interface changes will affect all the packages that depend on it (Stable Dependencіes Prіncіple – the principle of sustainable dependency). Therefore, in Figure 56 domaіn asset package (subject area property) require a more stable interface than leasіng packet data mapper (reducer rent). Often, more stable packages contain relatively more interfaces and abstract classes (Stable Abstractіons Prіncіple – the principle of sustainable abstraction). Dependency relationships are not transitive. If you change the class of the package domain ownership, you can change the class of the packet domain rent (leasіng domaіn). But these changes do not necessarily go through the presentation of the lease (leasіng presentatіon). (They pass only if the subject area rent changes its interface.) Some packages are used in so many places that you can get lost in the lines of dependencies coming to them. In that case, the convention, according to which on the package indicate the keyword «global». The UML packages identified as design, allowing packages to import classes from one package to another and combine them using keywords according to their designation. However, the rules for this type of elements differ greatly in different programming languages. Aspects of packets Figure 56 diagram the structure of two species present. One – the structure of the application layer: Presentation (presentatіon), subject area (domaіn), inverter data (data mapper) and the database (database). Another – thestructure of the subject areas: rent (leasіng) and property (asset).

Figure 57. Dividing the figure 60 on the two aspects

84

Chapter 10. Оbjеct Dіagram. Packagе Dіagram

It can be made more transparent if we divide these two aspects of the way it is done in Figure 57. This diagram can clearly see every aspect. However, these two aspects are not true package as viewed classes may be combined into a single package. This problem is a reflection of the problem of hierarchical namespace in a programming language. Although diagrams similar to those presented in Figure 57, are not included in the standard language UML, they are often very easy to explain the structure of complex applications. Implementation packages Often there is a situation when a package defines the interface that can be implemented in many other packages, as shown in Figure 58. In this case, the ratio of implementation means that the gateway database (Database Gatewau) defines an interface, while the other classes provide a gateway implementation. In practice, this may mean that the package Gateway database (Database Gatewau) contains interfaces and abstract classes, which are fully implemented in other packages.

It is generally placed interface and its implementation in different packages. Indeed, the client package often includes an interface that must be implemented in another package. Suppose that you need to provide some user interface (UІ) switches (controls) for switching on and off of an object. Suppose he has to work with a variety of devices such as heaters (heaters) or lamp (lіghts). Switches UІ should call the methods of the heater, but switches do not have to depend on the heater. To avoid this dependence can be defined in the packet switch interface, which is then implemented by each class, working with these switches, as shown in Figure 59. Here is a sample template Separated Іnterface (Divided interface).

Figure 58. Package implemented by other packages 85

Fundamentals of UML

Figure 59. Determination of the requested interface on the client package

When used diagrams packages Charting packages supremely comfortable in large size systems to represent the picture of dependencies between the basic elements of the system. These diagrams well correspond to the standard program structure. Drawing diagrams of packages and dependencies helps to control depending on the application. Charting packages are a compile-time grouping mechanism. To represent the layout of objects at run time chart used composite structures (composіte structure).

1. Application model is complete only if it contains at least one of each type of diagrams: a) yes; b) no. 2. Component diagrams are always needed in the design: a) yes; b) no. 3. For modeling I should choose one of the approaches - top-down or bottom-up ° but I can not combine these two methods: a) yes; b) no. 4. It has been proven that taking into account the specialization allows to increase productivity: a) yes; b) no. 86

Chapter 10. Оbjеct Dіagram. Packagе Dіagram 5. Design patterns are a part of the UML specification: a) yes; b) no. 6. Refactoring is not a part of the UML specification: a) yes; b) no. 7. Most experts agree that patterns and refactoring can improve the code: a) yes; b) no. 8. The UML is a standard, and all developers agree that it should be used: a) yes; b) no. 9. Use of modeling package is a prerequisite of design process: a) yes; b) no. 10. As a rule, all UML-modeling packages can effectively generate whole, complete application on the basis of models: a) yes; b) no.

87

Fundamentals of UML

CHAPTER № 11

Cоmmunіcatіоn Dіagram. Cоmpоsіtе Structurеs. Cооpеratіоns Brief content: Elements of cоmmunіcatіоn dіagram Cооpеratіоns

Elements of cоmmunіcatіоn dіagram Communication diagram (communіcatіon dіagrams) – isa special kind of interaction diagrams that focus on the exchange of data between the different actors of cooperation. Instead of drawing each participant in the form of lines of life and show a sequence of messages, positioning them vertically, as is done in sequence diagrams, communication diagrams allow arbitrary placement of participants, allowing to draw a connection, showing the attitude of the participants and use the numbering to represent the message sequence . Figure 60 shows a diagram of communications for centralized management. It is possible to see how the participants are connected with each other. Besides displaying links that are instances of Associations can also show the temporal relationships occurring only in the context of the interaction. In this case, the connection between «local» (local) from the object Order (Order) to the object Product (Product) – isa local variable, and other time constraints are the «parameter» (option) and «global» (global). Numbering style in Figure 60 a simple and common, but he UML language is not permitted. In accordance with the rules of UML must adhere to the nested decimal numbering as shown in Figure 61. Despite its illegality, many experts prefer the linear numbering scheme. Nested numbering can be very difficult, in particular because the challenges can have a large nesting level, which leads to a sequence of numbers as 1.1.1.2.1.1. Also numbers in messages and letters can be seen. These symbols represent different control flows. So, A5 and B2 may be different flows; Posts 1a1 and 1b1 may be different streams, simultaneously attached to the message 1. The letters designating streams can be seen also on the sequence diagrams, although it does not provide a visual representation of the parallelism. Communication diagrams do not have a well-defined notation for the control logic. They allow the use iteration markers and protection, but do not completely determine the control algorithm. There are also special symbols for creating and 88

Chapter 11. Cоmmunіcatіоn Dіagram. Cоmpоsіtе Structurеs. Cооpеratіоns

deleting objects, but the key word «create» and «delete» correspond to the standard agreements. When applied communication diagrams Given the choice between a sequence diagram and a communication diagram is necessary to consider the following: sequence diagrams useful if you want to emphasize the call sequence and communication diagrams is best to choose when you need to focus on relationships.

One of the most significant features of UML 2 is the ability to turn the class into a hierarchy of internal structures. This allows you to break a complex object into components.

Figure 60. Communication diagram of the system of centralized management

Figure 61. Communication chart with nested decimal numbering 89

Fundamentals of UML

Figure 62 shows a class Vіewer TV (LCD), together with the interfaces it provides and which require. It is shown in two ways: using a ball-socket notation and listing via the object.

Figure 62. Two ways to represent the object Vіewer TV and its interfaces

Figure 63 shows the same class, divided internally into two parts, which provide and require different interfaces. Each part has a name in the form «ame, class», in which each of its constituent elements may be omitted. The components are not part of the description of copies, so they are highlighted in bold and not underlined. You can also specify the number of copies of a particular part. Figure 63 shows that each object contains a single TV Vіewer generator (Generator) and one control unit (controls). To identify the part that implements an interface, it is necessary to draw a connection provided by this interface. Similarly, to show the part in need of an interface, it is necessary to draw a connector, this interface provided. In addition, the connectors between the parts can be shown, or with a simple line or using a ballsocket notation. By the external structure, you can add ports (Figure 64). Ports allow you to group required and provides an interface to the logic of interaction that the component has with the objects of the external world. When multiple structures Composite structures are new to UML 2, although some of the old methods of implementing such ideas. The correct approach to the distinction between packages and composite structures is that packages are a compile-time group and composite structures are the group runtime. And if so, they are better suited for display components and methods of their division into parts; therefore, a lot of these notations used in the component diagram.

Cооpеratіоns The UML standard of cooperation are considered as part of the composite structures, but collaboration diagrams in reality quite different from the composite structures. Consider the notation of the auction. In any auction (Auctіon) can 90

Chapter 11. Cоmmunіcatіоn Dіagram. Cоmpоsіtе Structurеs. Cооpеratіоns

participate vendor (seller) to the buyer (buuer), a lot of things (lot), and any suggestions for buying (offer). These elements can be described in terms of the class diagram (Figure 65) and possibly through multiple interactions diagrams (Figure 66).

Figure 63. Inside view of the component

Figure 64. A component with multiple ports

91

Fundamentals of UML

Figure 65 shows is not an ordinary class diagram. Firstly, it is enclosed by a dotted ellipse represents an auction cooperation. Secondly, in the so-called co classes it is not classes, and the roles (roles), which are implemented during the execution of cooperation, so their names start with a lowercase letter. Comparison of actual interfaces or classes roles cooperation is nothing unusual, but nonetheless this is not required. The diagram of interaction of participants referred to a little unusual. In cooperation naming scheme is as follows: «The name of the participant / role name: the name of the class». As always, all of these elements are optional.

Figure 65. Cooperation with her classes and roles

Figure 66. The sequence diagram for auction cooperation 92

Chapter 11. Cоmmunіcatіоn Dіagram. Cоmpоsіtе Structurеs. Cооpеratіоns

Application co-operation can be defined, marking its presence in the class diagram, as shown in Figure 67, which shows some classes of applications. Links from cooperation to these classes, show how the classes play different roles defined in the cooperation.

Figure 67. The presence of cooperation

When applied cooperation Cooperatives provide a way of grouping elements interact when roles are performed by different classes. However, in practice they are very seldom used.

93

Fundamentals of UML

CHAPTER № 12

Іntеractіоn Оvеrvіеw Dіagram. Tіmіng Dіagram Brief content: Elements of Іntеractіоn Оvеrvіеw Dіagram Elements of Tіmіng Dіagram

Elements of Іntеractіоn Оvеrvіеw Dіagram Charts review of interaction – isa combination of activity diagrams and sequence diagrams.

Figure 68. Іntеractіоn Оvеrvіеw Dіagram 94

Chapter 12. Іntеractіоn Оvеrvіеw Dіagram. Tіmіng Dіagram

We can assume the interaction diagrams chart review of activities in which the activities are replaced by small sequence diagrams, and sequence diagrams, broken by a notation activity diagrams to show the flow of control. In any case, they are quite unusual mix. Figure 68 shows an example of a simple chart of this type. This chart describes the process of compiling and formatting the report orders. If the client is external, that delivers XML data, and if the internal, the information is taken from the database. Small sequence diagrams show the two alternatives. After receiving the report data is formatted; in this case, the sequence diagram is not provided, reference is made to it.

Elements of Tіmіng Dіagram Timing diagrams – is another form of interaction diagrams, which accentuated in the time limits, either for a single object, or what is more useful for a group of objects. Consider a simple scenario, based on the use of the pump (Pump) and the heating element (Hotplate) in a coffee maker (coffee pot). Let the rule, which states that between the pump, and the inclusion of a heating element must pass at least 10 seconds. When the water tank becomes empty (waterEmptu), the pump is turned off and the heating element can not be switched on for more than 15 minutes. Figures 69 and 69 show alternative ways of presenting such time constraints. The main difference is that in Figure 69 changes the state transition denoted by one horizontal line to the other, and Figure 70 the horizontal position remains the same, and changes in the state denoted by a crossing horizontal lines. Style presented in Figure 69, is to be preferred when the conditions a little bit, and the style, as it seemed in Figure 70, is the best, with a large number of states. Dotted lines by which the designated time limits {> 10s}, are not mandatory.

Figure 69. The timing diagram in which the state represented as lines

95

Fundamentals of UML

When used timing diagrams Timing diagrams useful to indicate the time intervals between changes of state of various objects.

Figure 70. The timing diagram in which states are represented in the form of domains

96

Laboratory work #1

Laboratory works Laboratory work # 1 Design of hydroponic system Description of the problem Imagine that you need to develop software for greenhouse agriculture using hydroponics. The plants in this sector are grown without soil in a special nutrient solution. For normal growth and maturation of the crop must be respect for the cultivation. Management of various parameters hothouse – enoughtime-consuming task for a man, because you need to watch them around the clock. Therefore, adherence to the cultivation of specific plant mode control greenhouse installation is carried out by means of automatic devices. On the mode of cultivation is influenced by various external indicators, which must be maintained within a predetermined range. This may be the temperature, humidity, light, an acid soil and other factors, which in this case are not considered. To measure these parameters are used sensors from which information comes in. Sensors are the «eyes» and «ears» of the system, without the need to enter the information to carry out with the help of a human operator, while neither of which automation can not be considered. Imagine operator who every ten minutes passes and captures greenhouse thermometer readings in the journal. For such a system necessarily presence of actuators, such as heaters, lighting, fans, controllers fertilization. These devices –«hands» of the system, with the help of which the change in external conditions, such as temperature or acidity of the soil. Changing the terms of the plan is based on the cultivation of plants, which stores information about the time and the necessary actions in these moments. For example, for some plants need to 15th day of growth maintaining a temperature of 25°C, including 14 hours of light, and then lowering the temperature to 18°C in the rest of the day. To monitor the ongoing processes you want to display the current state of the system with the possibility of exposure to the operator and logs of what the magazine. Now that we have understood in general terms what the system should do, it is possible with the help of diagrams Use Case (behavior scenarios) to determine the system objects and actions that these objects must produce. Getting Started with Use Case Start the Rational Rose and create a new empty model. To do this, click the Cancel button in the window shown in Figure 1. This will be our working model, which should be reflected, and all the nuances of the future hydroponic system. Go to the diagram Use Case, as shown in Figure L1. Creating new elements Rational Rose provides several ways to create new items in the model. 1. You can create items using the context menu, as shown in Fig. L2. 97

Laboratory works

2. You can create items using the Menu => Tools => Sreate. 3. You can create items using the line tool. In the first case, the element is generated directly in the model, but the icon is not included in any of the diagram. After creating element, thus placing it to the selected chart. In the second and third case, together with the creation of the icon element is placed on the current chart automatically, which in our case exclude one intermediate step. When you create elements using the menu Tools program provides the ability to create all the elements that could be included in the current chart, whereas when creating the tool bar the user is limited to the creation of the elements included in accordance with this line of icons. We will use the third option because of the greater simplicity and clarity. To do this, you must read the contents of the string instruments, the default for this diagram.

Figure L1. Activating the Use Case diagram

Figure L2. Creating an item using the context menu 98

Laboratory work #1

Toolbar After activation diagrams Use Case, string instruments chart assumes the form shown in Figure L3.

Figure L3. Toolbar Use Case diagram

By default, the tool consists of ten icons. Some are only available in this diagram, but there are some that may be present on different charts, while fulfilling the same function. Selection Tool The main tool that allows you to choose the chart elements, in order to make them proceed. If you do not create a new element, this tool is active. When creating a new chart element you must select the tool on the toolbar button «sticks», and after the establishment of necessary again to switch to Selection Tool. Text Box This tool allows you to create an arbitrary label on the chart that is not tied to any element. To create labels must click Teht Box, the cursor changes to a vertical arrow and click on the point chart where you want to create a label. In certain points in the corners of the square box, you can enter a label. Note This tool creates an element of notes, allowing him to enter and adopted during the analysis solution. Notes can contain plain text, code snippets and links to other documents. Note Typically, the window is connected to the other elements of the chart using the tool Anchor Note, in order to show which element is the chart observations (Fig. L4).

Figure L4. Пример использования Note

This item does not have a limit on the number of input characters and the window Note can be stretched in order to accommodate the desired text. When you activate this tool, the cursor takes the shape of a cross. The context menu for the icon Note allows the installation other than the font color to establish lines and fills. 99

Laboratory works

Note Anchor This tool allows to connect the element with an element Note the diagram including another element Note. In order to attach the note to a chart item, you must select the tool Note Anchor, the cursor takes the form of a vertical arrow, click the icon Note and, without releasing the mouse button, «drag» line to the desired icon at which the mouse button to let go. Package This tool allows you to create containers that may include group elements Use Case in the diagram can be used to determine the larger scenarios behavior of objects with further detail. Moreover, the containers can include other containers that can create significant nesting level of detail. Use Case This tool allows you to create simple forms of behavior scenarios of system objects. This representation of the system in terms of actors (actors), that is carrying out certain functions in the system. Use Case can display: – behavior patterns of individual objects in the system; – sequence of related transactions represent an object or a system; – obtain certain information objects. Creating Use Case is necessary to: – formalize the system requirements; – collaborate with the future users of the system and subject matter experts; – test the system. Ассtоr This tool is used to create the actors in the system. Diagram Use Case icon astor often represent users of the system, in order to determine the tasks performed by users and their interaction. Normally icon Astor represent an object that: – interacts with the system or using the system; – transmits or receives information to the system; – it is external to the system. Astor let you know: – who use the system; – Who is responsible for maintenance of the system; – external hardware is used by the system; – Other systems that have to interact with the system. Unidirectional Association This tool allows you to indicate the connection between the elements. Use Case Diagram these relationships can be defined between the use case and actor. Creating a Use Case diagram for hydroponic system After learning the basic tools of chart you can create scenarios of system behavior. According to the statement of the problem there is some plan for plant growth. It should be entered into the system by the operator. To reflect this process 100

Laboratory work #1

will create a new actor (Actor) and assign it the name "Operator". Create a new use case icon and name «to create a plan of cultivation», then it is necessary to connect these icons associative link, as shown in Fig. L5.

Figure L5. Use Case Diagram icon after adding «Operator»

Note that the plan is to enter the growing system and processed. Also the operator must be able to browse the system protocol. Create a new object and name it controller. Connect its connection with the element «to create a plan of cultivation». Create a new icon «create a protocol», which is connected to communicate with the controller. Now we have a diagram shown in Fig. L6.

Figure L6. Use Case Diagram icon after adding «controller»

Also, the controller has to control actuators. To display this process will create a use case called «control devices» and a new actor «Devices». It is also necessary to create a new character, «Sensor» and use case «to measure the performance of the medium». Once connected, the connection of these icons, you should get the image shown in Fig. L7. Thus, in the final version, we received the following system requirements management greenhouse farming: 1. The operator must be able to set up of cultivation; 2. The operator must be able to view the activity log system; 3. The system should receive information from the sensors; 4. The system should be able to control external devices based on the performance of sensors and introduced the cultivation plan.

101

Laboratory works

Figure L7. The final form of Use Case diagrams

Laboratory work # 2 Using the Deployment diagram for the analysis devices Purpose Figure Deployment (topology) is designed for the analysis of system hardware. With this chart designer can analyze the required hardware configuration, which will operate the individual processes in the system, and describe their interaction with each other and other hardware devices This type of chart also allows you to analyze the interaction between processes running on different computers in the network. This type of chart is the easiest-Rational Rose, because it uses only two basic icons. To activate the chart to select: When activated Deployment diagrams string instrument takes the form (Fig. L8).

Figure L8. Toolbar Deployment diagrams

Processor The processor – adevice capable of performing processor program must have a name, which, however, has nothing to do with other chart patterns due to the fact that the processor does not denote the software and hardware. Create a system for our new processor and call it «Computer». Let's see what possibilities at our disposal program in the context menu activated by right mouse button (Fig. L9). 102

Laboratory work #2

Figure L9. The context menu for the icon Processor

– Open Specification – opening a window element specifications. – Select In Browser allows you to quickly find the item in the Browser. – Show Scheduling allows you to enable or disable the display of the order implementation processes. – Show Processes allows you to enable or disable the display of processes in the diagram. – Stereotype Display allows you to change the stereotype of the show, but usually for this type of chart patterns are used. – Format allows you to change the format of the element. Processor specification If you select the context menu is activated Specification Setup dialog box specifications processor consisting of two tabs. When activated, the user is taken to the tab General (main), shown in Fig. L10. On the General tab are given the opportunity to change the name element and enter an optional description for the item in the Documentation. In addition to standard buttons preservation and denial, at the bottom there is a button Browse, which activates the submenu that provide additional options for viewing.

Figure L10. General Tab Processor Specification 103

Laboratory works

Tab Detail (detail) is more saturated (fig. L11). Here the user can enter additional data characterizing the processor. Field Characteristics (data) is used to specify the physical characteristics of the hardware used, such as manufacturer, model, the amount of disk and memory, etc. This information will not be displayed on the charts, but it will help to define the general requirements of the system hardware.

Figure L11. Detail tab Processor Specification

Field Processes (Processes) allows you to create a list of processes that run on the processor. Each process represents a major or program, or an active object system. In order to show the order of execution of processes on each processor, we can use a group of switches Scheduling. Installation of the following scheduling processes: – Preemptive – aprocess with a higher priority displaces processes with a lower priority. The system allocates processing time in such a way that processes with a higher priority is performed first, and can at any time abort the process of low priority to execute the higher priority process. At the same processes with the same priority is obtained from the system about the same CPU time after which the execution is passed to the next process. For example, the Microsoft Windows operating system 95 and above. This item is selected by default. – Non preemptive – aprocess running on a processor, provides full control for as long as he did not pass control to another process. For example, working system Microsoft Windows 3.11. – Ccyclical – allprocesses is allocated an equal amount of CPU time. – Manager – switching between processes is carried out by a special supervisor, which is on the algorithm manages processes. – Manual – theprocess controlled by the operator. 104

Laboratory work #2

For hydroponic system that does not impose requirements for the order execution process, you can leave the parameters set by default. Device This tool allows you to create a device object in the diagram is not able to execute programs. Each device also includes hardware and should be common for this type name, such as «modem» or «terminal». Connection This tool allows you to link the devices and processors. Connection is a certain type of cable or other connection, such as connection using network cards, serial or parallel port connection or the «Earth satellite». Unlike the real connection in the diagram can be shown by the direction of movement of information of the compound and it is believed that the connection is always bi-directional. The device hothouse Now you can create a device such as shown in Fig. L12.

Figure L12. Devices hothouse

The diagram shows that the operation of the system is planned on a single computer connected to the sensors and actuators. Sensors are already planned two: a temperature sensor and a sensor of acidity, which will be called the pH sensor. The actuators presented a lamp, heater, fan, water tank and the tank with fertilizers. The lamp should be included with a lack of lighting, but the light sensor means is not provided, the lamp should be lit whenever the system goes into «day» on and off when the system goes into «night».

105

Laboratory works

The heater and fan should provide the necessary for the cultivation temperature. By reducing the temperature of the heater must be switched on and when it is increasing – thefan. Water tank and tank for fertilizer will be used to change the level of acidity. By increasing the acidity of the water tank must receive water, wherein the pH level will decrease. By lowering the acidity of the tank receives fertilizer, and the level of acidity increases.

Laboratory work # 3 Creating a model system behavior by means of State Diagram Appointment chart Creating a model of behavior of objects allows you to fully describe all the states of the system and transitions to these states during operation, as well as some of the algorithms of interaction between objects. The only drawback – thatis what is the content of this chart has no effect on the resulting code of the program, and it can create a programmer misconception that without a model of behavior can do. But it is not. The model allows to look at the behavior of the resulting program object from the outside, because the main purpose of object-oriented programming – tocreate objects endowed with a certain behavior in the future and that will produce the work in the program code. And this type of chart allows you to clearly present all the behavior of the resulting program object in the form of graphic status icons. Creating pieces classes In order to begin to create a model of behavior, you must add the class model, based on which of these objects will be created later. Based on the previously discussed devices, the following candidates for the creation of classes: – Environmental Controller – controlleractuators; – Temperature Sensor – Temperaturesensor; – pH Sensor – Sensoracidity; – Heater – heater; – Cooler – fanfor temperature reduction; – Light – Illuminator; – WaterTank – storage of water; – NutrientTank – storage of fertilizers. The use of English names allows you to not be afraid that in the generation of the source code of the selected programming language process can fail in the event of a conflict with Russian names. To add a class in the model, go to the Browser window, and on the line to do Logical View RClick => New => Class, as shown in Fig. L13. Change the name of the New Class to the Environmental Controller, and the first class is ready. Similarly, add the rest of the classes, and you can start to create a model of behavior.

106

Laboratory work #3

Figure L13. Creating a new class in the Browser

Creating Statechart diagrams In our system, the most complex behavior has class EnvironmentalController, so we will disassemble the creation of a model of behavior from his example. To create the diagram there are several ways. 1. Create a menu through Menu => Browse => State Machine Diagram. 2. Create a line by means of tools with icon 3. Statechart. 4. Select New Statechart Diagram from the context menu class. The 2000 version is devoid of such complications, because the ability to create any chart anywhere, this activates the selection window of the diagram (Figure L14).

Figure L14. Selecting Statechart diagrams or Activity

Using this dialog box, the user can select the chart for its current purpose, to create a new, delete or rename an existing one. When you create a new chart will be asked to choose between two possible (Fig. L15). To create a chart, select the type Statechart.

107

Laboratory works

Figure L15. Select the type of chart

Tools diagrams Statechart After activating the chart the following tools become available (Figure L16).

Figure L16. Инструменты Statechart Diagram

State The tool allows you to reflect the status of State or situation during the life of the object, which corresponds to a certain position of an object or an event they wait. Each state is a cumulative history of behavior of the object. His name must be unique within a class, as the state with the same name are considered to be a representation of the same states. In the current icon State action can be reflected at the input, the output from the state action is not related to events or a reaction to events. Start State The tool lets you create a Start State icon started. For diagrams Statechart it represents an event that takes an object in the first state in the diagram. End State Tool End State icon allows you to create finished. The direction of the transition can be set only in the active icon, however, no limits on the number of transitions in the End State, and the number of elements in the diagram is not imposed. State Transition State Transition Tool lets you create an icon state transition, which means that the object moves from one state to another in the event of a particular event or to change certain conditions. The user can specify multiple transitions from one state to another, when each such shift is performed upon the occurrence of different events or subject to different conditions. 108

Laboratory work #3

Transition To Self Transition To Self tool allows you to create transition icon in the same state from which the transition. This transition is similar to the State Transition, however, he makes a transition to another state upon the occurrence of certain events. Thus, when an event occurs, it is processed and after the processing object is returned to the state it was in before the event. The first steps in the creation of charts The first step to create a chart is to create a point of starting work. Create it by pressing the Start State. Typically, the first state of the system after the start of work will be waiting for an event. And in our case, we will not make exceptions. Create a new state (State) and connect it to an arrow State Transmission to the starting point. Each state or event must have a name, so we assign the name of expectations RClick => OpenSpecification => General => Name => Idle, which means «expectation» (Figure L17).

Figure L17. General tab for specifications state

Figure L18. wait state

109

Laboratory works

Condition sensor test The aim of our controller is to maintain the preset parameters of the medium greenhouse temperature, light exposure, concentration, pH. In order to maintain these parameters according to the plan, it is necessary to read the current state of the environment by means of sensors. In our case, we will not count on the most intelligent sensors. Sensors will have their processor and will only issue a request for changed parameters of the controller. Thus, the next state will poll the sensors. Add to this state diagram is called Testing Environment and join with the state Idle. This event is called Timer. It is understood that the controller has a built-in clock, which after a time delay is initialized event. We now consider in more detail what needs to be done to test the parameters of the medium. Activate the controller interrogates sensors are temperature and pH. In order to reflect that the survey sensor occurs within a given state, it is necessary to add a new action (Action). To do this, in the Actions tab from the context menu, select Insert. Please select the action by double clicking the mouse, and get into the dialog box shown in Figure L19.

Figure L19. Configuring Actions

Here we can switch between the action (Action) and sending messages (Send Event). The difference between these points is that the action is carried out by class, for which we are creating a diagram of a state that is here called method of this class, and sending a message sent to an object of another class, the method is called with this message. This property is set in line Send target. You can also specify the name of your class method in a row Send event and arguments in a row Send arguments. You can set the time in which there is a marked effect. It offers a choice of four states: 110

Laboratory work #3

– On entry indicates that the indicated action must be carried out at the entrance to the state before the rest of the action. – On exit indicates that action should be taken before the exit of the condition. – Do – actionsperformed within the state of the exit. If you typed a few such actions, it is almost certain they can be identified as a separate state diagram. – On Event – actions in response to certain events that are processed in the current state. When you select this option and the opportunity to fill the event (Event), options (Arguments) and the conditions under which this action is processed (Condition), ie it can happen that the event occurred, and the condition of its processing did not come. This option is useful when processing an event that does not cause a transition to another state and is reflected icon Transition To Self. It should be noted that if you change these settings, and change the inscription on the status icon. Events are recorded using the ^ symbol in front of him. Procedure: at the entrance: entry:, exit: exit :, during operation: DO :, actions post: event :. Processing conditions is shown in square brackets. This notation is quite comfortable and allows without activating the properties window, made at a glance. Fill in the event, as shown in Fig. L19. By analogy fill action for the survey and obtain a pH sensor Fig. L20.

Figure L20. The status icon for testing environment after change

The output of the loop diagrams After the test the state of the environment, must be brought to normal performance by the inclusion of appropriate actuators. To reflect this action will create a state Adjusting Environment, which is connected with the state of Testing Environment. After setting up the environment the system goes into waiting for the next point in time. To reflect this by using the arrows connecting the state Adjusting Environment and Idle. However, we have obtained a system with an infinite loop. She has no way out. But we know the system must finish the job at the moment when the crop is ripe. Key maturation will assume the expiration of plant growth as planned cultivation. To reflect this, we introduce the state AnalysingTime, which is connected between the Idle state and Testing Environment.Peretaschim end of the arrow on the Timer AnalysingTime and join his new arrow Testing Environment. Add End State, connect this state with AnalysingTime, fill condition RClick => OpenSpecification => Detail (Fig. L21), saying that the transition takes place only when the elapsed time of plant growth. This window is filled with practically the same field as previously discussed, so we will not dwell on it. The only thing I would note is that the arrow can be transferred directly from here, change the position From (from) and So (much). 111

Laboratory works

Figure L21. Filling conditions make the transition

Adding comments To add the latter have not yet used our badge, we introduce a chart comment, which is connected by means of an icon Anchor Note to Item with the state Analysing Time, and should have something like this (Fig. L22).

Figure L22. The state diagram after adding comments

Setting up the environment We write more, which must pass the state system for setting the medium in accordance with the plan of growing, with the following assumptions 112

Laboratory work #3

– to increase the temperature in a greenhouse is necessary to include a heater; – to reduce the temperature you need to turn on the fan; – to switch to the «Day» is necessary to switch on the lights; – to switch to the «Night» you must turn off the lights; – to reduce the pH of the solution is to add to the water; – to increase the pH of the solution is to add to the fertilizer. And perhaps the simultaneous operation of the heater, lights and water valve, but it must not be possible simultaneous operation of the heater and fan, as well as the simultaneous entry of water and fertilizer. The analysis of the necessary actions, it is easy to notice that the above set can be divided into three independent parts are: – temperature setting; – adjusts lighting; – Adjusting the pH level. Since we have assumed that the processor we have only one, these states will be completed sequentially. But if every part of your CPU is used, it would be possible to create a self-contained classes for managing these conditions. Rational Rose provides the ability to create nested state diagrams, which is convenient for more details on each state. We use this in our case. Add three new state Adjusting t (temperature setting), Adjusting Light (setting lighting) and Adjusting pH (pH adjustment). To do this, add new states right in the icon Adjusting Environment. Before adding the icon is highlighted frame, and after the addition will automatically move apart to fit into it an added element. Change the direction of incoming and outgoing arrows so that incoming point to Adjusting pH and exiting came from Adjusting t, and connect these states successively. Now write out what is happening in these conditions (Fig. L23).

Figure L23. Setting up the environment 113

Laboratory works

Adjusting temperature is only when it is a change that and show function tempDown tempUp. When one of these events, the temperature is compared with the one that must be planned, and if it is less, the heater is activated, and if more - fan. However, if the temperature reaches a normal level, the fan and heater are switched off. Similarly happens with pH. For lighting a lamp turns on when the time comes to light on and off upon the occurrence of night-time. Hiding nested states The chart has become quite difficult to see. Imagine that you have a dozen such states. The overall picture is lost when a large number of bulk states. Rational Rose allows you to hide unneeded currently invested state. To do this, select a state and then select the Menu: View => Hide Substates. In the lower right corner of the status of an asterisk, and the incoming and outgoing arrows take the form shown in Fig. L24, in a state Adjusting Environment. State History The only thing left is not considered in this type of chart is setting State History. Enabling this setting allows you to show that the next time the system enters the specified state, it should not start from the beginning of states and go directly to the last state from which came out, that is when you first log in a position to produce individual action that the next time prodelyvat no longer needed. For example, when you first log in logging mode messages need to create a log file that on subsequent calls to the regime do not need to rebuild. In Figure L24 shows that the installed configuration State History reflects the letter H in the circle.

Figure L24. The final version of the state diagram of the controller environment 114

Laboratory work #4

Logging starts when changes in conditions (Environment Changed). It then creates a file Log (Create Log) and the system goes into standby (Log ready). If you want to save the changes are recorded (Logged), and the system reverts to the idle state. At the same time the next time you need to start with the state Log ready, rather than by creating a protocol.

Laboratory work # 4 Creating Active Diagram Appointment activity diagrams Activity Diagram (activity diagram) allows you to simulate the sequence of business processes or transactions on the basis of the class activity and the activity or activities to the state. This type of chart can be used to simulate different types of actions. For example, the financial services company can use this type of diagram for modeling the flow of financial documents, passing paying bills or orders. The company that creates software products that can use this type of chart to track the development and creation of software. Active Diagram – isa special kind of state diagram. In this type of charts used by the majority of the signs – they are signs of activity, the transitions between which are caused by the completion of certain operations and the beginning of others. Differences between the Activities and Statechart The main difference between Activities and Statechart Diagram that in the first case the ground – action, and in the second – thestatic state. This Active Diagram is more suitable for modeling workflows, and Statechart for modeling discrete states of the object. Create activity diagram Select Browse => State Machine Diagram and create a new Active chart as shown in Fig. L25.

Figure L25. Create activity diagram

Toolbar Once the chart is activated, the string instruments would be as follows (Fig. L26). 115

Laboratory works

Figure L26. Toolbar activity diagrams Activity (Activity) Activity icon represents performed tasks or perform certain actions during the life of the object. This icon, in general, similar to the State, but if the State icon usually denotes the expectation of an event, the icon Activity indicates immediate action. State Transition State Transition – transitionfrom one state to another, or upon completion of certain actions in the beginning of another. This icon can also characterize the object of getting a message to further processing. State Transition can be performed between the Action-Action and State-State, and between State-Action and Action-State. You can also install multiple transitions between two states or actions. Each transition is unique and shows the reaction of the object on a particular message. Thus, you can not create multiple transitions between the two states with the indication of the same message. Synchronizations Icon Synchronizations to determine independently performed actions. This action is divided into several independent and carried out only at the end of all existing facilities continues. This icon is a horizontal or vertical line indicating the timing of work. Decision Decision allows to show the dependence of the future work of the external environment, or solutions. This icon is similar to the language commands if or case and can have more than two outputs, but usually use a choice of two junctions defined Boolean expressions. Swimlanes Swimlanes (literally translated as «swimming lanes») allows you to simulate the sequence of actions of various objects and their relationships. With this element, you can model business processes organization, reflecting the various units on the chart and the objects plays an important role in the business model. Swimlanes allows you to show who perform certain roles in the process. To do this, you must move the icons, or the activity of states in the area of certain units, separated from the rest Swimlane. Start creating charts Now let's see how to change the chart, if you do not create a state diagram and activity diagram for object EnvironmentController. Create a chart start by placing an icon on the diagram and the state of Start State Idle. Connect their relationship State Transition and call it the New Planting. 116

Laboratory work #4

In order not to enter again these icons, you can select them in the already established Statechart diagram and move the newly created. Now, remember that before you go into a wait state, the controller must set the timer, the duration of the cultivation, the waiting time between polling sensors. In this case, you can immediately divide the functions performed by a timer and a controller, which will create some separators Swimlane for these objects. Editing specifications Swimlanes Add new dividers Swimlanes timer and controller. These separators will be named the program automatically NewSwimlane Rational Rose and NewSwimlane1, which, of course, need to be corrected. To do this, activate the properties Swimlane. To access the properties, you must select a title line and then RClick => OpenSpecification. This opens the window shown in Fig. L27.

Figure 27. Edit Properties Swimlanes

You can change the name and the name of the class from which the object. In our case it plantTimer. And of course, it is possible to document the resulting Swimlane. Enter the information as presented in the figure. Similarly change the information for the next line, which represents the Controller, derived from class Environmental Controller. Now you need to «drag and drop» icons in the input column Controller, in order to show that the main actor in this case is exactly it. If you have done all the steps that should get what is shown in Fig. L28. However, to set the timer action is necessary to make the installation. Reflect this point by adding a new icon activity. Setting specifications icon activity For the icon activity from the following changes in the properties window, as shown in Fig. L29. 117

Laboratory works

Figure L28. Added to the chart activity Swimlanes

Figure L29. Properties icon activity

Change the name to SetTimer. Open the Actions tab and add a new action RClick => Insert. Go to the properties of the action and get the window shown in Figure L30. 118

Laboratory work #4

Possible options: – On entry – the action takes place at the entrance to this type of activity; – On exit – the action takes place at the outlet of this type; – Do – the action takes place between the actions of input and output; – On Event – the action takes place in response to a specific event. If the action is in response to a specific event, the opening arguments of the input field of the event.

Figure L30. Setting specifications

In the box type, you can specify what type of activity will be used. This can be Action (action) or the Send Event (sending a message). – Action can be used in order to prove that this type of activity does not interact with another object, and the action takes place within the object. – Send Event it shows that there is an interaction with other objects by sending messages. Here you can enter the name of the message, its arguments and the message destination, as is done in this case. Transitions tab shows all the ins and outs of activity icon (Figure L31). You can review in detail all incoming and outgoing events from a given state and change their specifications right from this window. Swimlanes tab shows with what Swimlane Activity icon or interacts State. If everything is filled out correctly, you should be able to state shown in Fig. L32

119

Laboratory works

Figure L31. Transitions tab

Figure L32. Diagrams after filling activity icon

Laboratory work # 5 Create icon analysis time Diagram Statechart, created earlier, this sign was to analyze the time that you can paint more. Adding icon get the time From the idle state controller must be removed timer, then it checks the current time of cultivation for its completion. Assume that the timer can give the time that has elapsed from the start of planting, and the controller should get this time to analyze whether it is time to finish the job. 120

Laboratory work #5

To display this process will create a new icon Activity and call it GetCurrentTime, which is connected with the event icon Idle Timer. GetCurrentTime add an icon to reflect the reference to the timer of the current time. Create ReturnTime icon to the Timer icon and introduce solutions for the controller (Fig. L33).

Figure L33. Activity diagram after entering icon solutions

To reflect the work of the controller is to be completed, will add EndState icon and connect it to the arrow on the condition that the transition should be carried out only when the ran out of time growing plants. Fig. L34 shows how the properties necessary to fill StateTransition that case. Adding solutions Icon decision became quite a good addition. Now there is an opportunity to show branching under certain conditions, and although this type of chart is not reflected in the resulting software code, but it allows you to accurately describe the sequence of actions when performing certain tasks, which show branching may be simply necessary. If you have programs that try to remember when you last again drawing flowcharts. Now it is happening less and less precisely because of the limited time for execution of projects and the availability of computers. At a time when access to a computer carried by appointment, no one could afford the luxury of reinventing the algorithm, sitting at the keyboard terminal. First, a block diagram, then – the code written by hand on sheets of perforated paper, and then only the terminal keyboard. Now things have changed, the program began to be created faster, but their support is becoming more time-consuming. In connection with the introduction of objects to exchange messages flowchart drawing programs has become much more difficult. But now, instead of flow charts, we have a program Rational Rose, which allows much easier and clearer to describe the algorithm of any complexity, and a large part of this simplicity and clarity bring such icons as the Decision (decision) and Swimlane (separator). In this case, the solution icon will denote the end of the plan tested for plant growth. To further simplify the task will use a specialized controller, which is 121

Laboratory works

programmed for the cultivation of a certain type of plant. If we remember that for keeping the plan meets the growing specialized class GrowingPlan, it is necessary to appeal to this class of controller to check whether the time was completed the cultivation of our plants.

Figure L34. Set properties for the State Transition

Process Synchronization In order to indicate the actions performed by the object GrowingPlan (plan of cultivation), add a new line in the chart Swimlane GrowingPlan and call it, and then add in the new action GrowingPlan ReturnAllTime. Now, to reflect that further work is necessary to obtain the two-time and current, and complete, we introduce a line of horizontal sync. Of course, in this case, it could have done without synchronization, if you create a sequence of actions reflecting the consecutive receipt of the data. In this case we have used synchronized to show an example of its application. After adding the timing chart will receive the form (Fig. L35). Line synchronization is typically included in the case where there are independent processors, which perform parallel tasks. If GrowingPlan had a processor that would allow to perform tasks in parallel, the synchronization would be vital. But in our case, it only shows that the further transition can not be achieved without data processing as a timer, and up cultivation, and only after both the object will return the requested information, the controller can perform its analysis and decide on further action . Usually, the clock line used in the design process the client-server when the client issues requests to multiple servers and are awaiting a reply from them, or in the design of business processes in several structural units of one office, where, for example, various documents are processed in the units, and then, at the end of the creation of all documents is their grouping into a single report. 122

Laboratory work #5

Figure L35. Figure after adding sync icon

Adding sensors poll Further, to obtain a picture of the controller Enter icon activity Testing Environment, which, as in Statechart diagram shows a survey of the sensors greenhouses. Algorithms survey sensors can be different. Algorithm selection depends on the system designer, his experience and preferences. The challenge here is that you must first create a workable system and its example to learn how to use the tool. Let us examine the different options for a sensor: 1. Create active sensors that will send messages to yourself when changing the controller and the controller will activate the actuators. 2. Poll sensors, one on immediate reaction to deviations. 3. Interrogate first all the sensors, and then comparing with the required values of the parameters laid down in terms of cultivation, activate actuators to bring these parameters in the proper condition. The first option involves the creation of several controllers of certain parameters of the medium that are not related to each other. From the point of view of an objectoriented design of the preferred embodiment. It will on the basis of the controller class to create controllers of various parameters and, most importantly, will allow to further expand the system by adding new controllers are additional parameters of the medium almost without affecting already working controllers. The second embodiment can also be implemented, but it is far away from the latter, which, again, for ease of creation of our training system we will take to implement. According to the accepted version of the survey required the temperature sensors and the pH is then compared to the necessary values and configure the environment by switching on or off executive devices and record a change in data parameters. The final version of the chart To reflect these actions add to the chart action icons TestingEnvironment, Writing, AdjustingEnvironment. We will not decrypt the content of these actions in order not to clutter the diagram, but will add the icons of decisions that direct action at 123

Laboratory works

change (IsChanged) medium and, if necessary setting (NeedAdjust) environment. This should get the diagram shown in Fig. L36.

Figure L36. Figure after adding all the action.

The final version of the chart obtained by the algorithm of the complete controller from the test environment parameters to configure them with report. Unlike Statechart Diagram here we did not paint the detail steps Testing Environment, Writing, AdjustingEnvironment, which then write out using nested charts. Nested in the 2000 version of the chart, you can create an icon for each state or activity. This feature allows you to not clutter up the chart itself, and create any number of nested, that not only hides unnecessary details, but also makes it easy to share a project team to work as programmers and easy to assemble the project back. If you look at the resulting graph, you will notice that the algorithm recorded in the minutes of going on to check the need for setting up your environment. This is because it is possible to change the medium without its setting. For example, according to the plan of growing need to adjust the parameters and indicators have changed in the desired direction by changing external conditions. In this case, write the data on the changes, but configure, ie include actuators, is not necessary. Creating an algorithm – a creative work, and each designer's algorithm may differ slightly in detail. But most importantly, Rational Rose allows you to create such diagrams that make the algorithm of the program clear, easy to read, understandable even to those who see it for the first time. Creating nested charts To create a nested chart, select the icon and go through TestingEnvironment RClick => SubDiagram => New Activity Diagram. 124

Laboratory work #5

This will open a new chart that in the Browser will appear as shown in Figure L37. Of course, here the name of the new chart with assigned when creating the program changed to TestingEnvironmentDiagram. Thus, the developer itself should see to it that these charts do not come into conflict with each other on the input and output state transitions and actions. This approach allows you to not pay much attention to syntactically correct docking charts of different levels, and to focus on the logic of the process. Yet, additional checks that will avoid difficult to detect logical errors later, but with the ability to enable or disable this check, when it is needed.

Figure L37. SubDiagram for Testing Environment in the Browse window

Figure L38. Diagram Testing Environment Diagram

Add the newly created diagram icons start and end, action icons obtaining the temperature and pH of receipt and, of course, use these icons to place the appropriate Swimlane. Thus, you should get the diagram shown in Fig. L38. If you now activate 125

Laboratory works

the context menu icon TestingEnvironment, then it appears to jump to the newly created chart TestingEnvironmentDiagram (Figure L39). We have received the enclosed chart, which is connected to the main. Of course, in this case, the nested chart is simple, but in other systems such diagrams can be complex enough to require the creation of an even deeper nesting. But its creation in Rational Rose will have no difficulty. Thus, it is possible to detail the algorithm of the program, starting with the implementation of the major problems and gradually breaking them down into smaller, down to performance of individual operators selected language.

Figure L39. Altered context menu icon Testing Environment

Now, as the workout you can create your own nested charts for icons Writing and AdjustingEnvironment. Diagrams are similarly considered.

Laboratory work # 6 Description of interaction using Sequence Diagram Appointment chart Continue creating a hydroponic system will chart the interaction between objects. In addition to the script the behavior of each object must be exactly is the interaction of these objects with each other, the definition of clients and servers exchange messages and the order between them. Messages are exchanged in sequence, and Sequence Diagram enable this exchange to receive the reflection time. During the operation of a complex system objects that are clients send each other various messages and objects are servers that handle them. In the simplest case, a message can be viewed as a challenge to the method of any class, in more complex cases, the server processor has a message queue, and the messages are processed asynchronously to them, ie, the server stores multiple messages in the queue, if you can not handle them right. Based on the reception and transmission of messages based multitask Windows, as in our case, for simplicity, creating a demonstration application, we assume that messages are processed immediately in the order in which they are issued to customers. 126

Laboratory work #6

Create a chart Create Interaction Diagram using the Menu: Browse => Interaction Diagram => New or the icon in the toolbar. This activates the window shown in Fig. L40.

Figure L40. Creating Interaction Diagram

Assign the value of the field Title Process. Here you can choose from two types of diagrams. These charts show the interaction of objects from different angles. Collaboration shows the interaction of objects regardless of time. Sequence in turn, is a time-reversal of interaction and represents the sequence of issuance by clients. Create a Sequence diagram. Toolbar chart If you switch to the diagram toolbar has been replaced with a new one which is now available icons Text Box, Note, Anchor To Item, Object, Message, Message to Self. The first three were considered for the previous charts here perform the same function, so we will not dwell on them.

Figure L41. Sequence Diagram Toolbar

Object Icon Object allows you to insert a new object in the chart. Each object is an implementation of the class, so it is possible to specify the class from which it was created. Message Message icon to create a message that is sent from one object to another. Because all interaction in object-oriented systems is carried out by means of messages between objects, classes should allow the sending or receiving messages. Message to Self This icon allows you to show that the message sender is also the recipient of it. 127

Laboratory works

At messaging some classes are clients receive messages, while others – servers and send messages. In the case when an object sends a message to itself, it is both the server and the client, which is reflected in the icon. Setting the lifetime of the object Add to chart two new object. The first is called Timer, second – Controller. To specify the name, you must first select the icon, and then just point the mouse in the middle of the icon and enter the name. By double-clicking the mouse on the icon to go through RClick => Open Specification activated dialog object parameters. For the Controller object is shown in Fig. L42.

Figure L42. Setting object

You can also enter the name of the object and the class, which is the realization of the object. For the controller, we have created a class EnvironmentalController, and so it will choose. For the Timer class has not yet been created, it is our omission, so long as you leave the field empty Slass. In the future, the best solution for our chart will add the Timer class in the class diagram. For realization of objects in the Options dialog box option is available Persistence, reflecting the lifetime of the object. The lifetime of the object – thistime from creation to destruction. Usually objects exist within their scope and are automatically deleted by the system when out of the area. This occurs when, for example, determined in the subroutine class object that is automatically destroyed upon completion of the subroutine. In C++, you can create and delete an object, without waiting for when it will make the system using the new command and delete. Typically for such an option, and 128

Laboratory work #6

even resorted to reduce executable. We know that when you create a program in Visual C++, the following definition: char s [10000]; will increase the executable file 10000 bytes for this variable will be reserved a place in the program data. However, creating an array using operators: char * s; s = new char [10000]; // Work with an array of practically does not lead to an increase in the size of the executable file, although assumes that the programmer releases the allocated memory to complete the program using an operator: delete s []; otherwise it will not be available for the system as a whole. A common solution in order not to forget to free the allocated memory, memory allocation will be in the class constructor and the release it in the destructor. Thus, you can adjust the following parameters of the object of life: – Persistent means that the scope of the object exceeds the lifetime. – Static active element exists throughout the work program. – Transient means that the lifetime of the object and the scope of the same. This option is assigned by default, and it is suitable for us both. In order to show that these properties describe the condition of all objects of this class, you can specify Multiple instances, but in our case it is not necessary. Creating a class from the settings window Now, remember that our Timer object Unknown class on which the object is created. Head over to the window object's properties, go to the Class field and press the «up arrow». This immediately opens a window class properties (Fig. L43).

Figure L43. class Properties 129

Laboratory works

Here you need to enter only the name plantTimer (it is the class responsible for the calculation of the current time of plant growth) and click OK. Now, in its sole discretion, you can hide or show the name of the class of the icon for the object, as shown in Fig. L44.

Figure L44. Showing and hiding the name of the class

Creating messages Proceed directly to messages. Select the arrow Object Message and the dotted lines connect the controller and timer. Then again, but from the timer to the controller following the first message. In this case, we mean that the very first message will specify the timer time, which occurs through the activation and transfer callback timer address. The second message is a message from the timer that a specified amount of time has elapsed. The PC compatible computer system clock to enable the timer to set a minimum 1/60 of a second. But in our system, such precision is not completely necessary. Plants grow slowly, and the temperature or the pH drops or increases the perceived value of at least several minutes. Therefore, for our timer acceptable value will activate once a minute. However, allowing arbitrarily set the amount of time, we have, firstly, to give our greater flexibility and, secondly, what is important, leave yourself a loophole for debugging. We can certainly set more or less time for the accelerated testing process. Select the first message and the context menu (RClick). Here we see the familiar point and click Open Specification New Operation. By means of the latter can add new operations (methods) to the class from which the object was created. Select this option and enter the name of the operation SetTimer (Fig.L45). And click OK. Contrary to expectations, we got back to our chart, and it has changed nothing. But this is only at first glance. If once again the context menu, then in it, besides those already described points will be present item SetTimer (), after which the selection arrow over the name of the message appears SetTimer. What has been done today? Without going into the class diagram, we added a new Timer class and method to it SetTimer. This manifested the power of Rational Rose, that the diagrams are related. Classes and methods are added to them in the place where it is most logical and understandable. And, if you make changes to the description of a class on any chart these changes immediately appear in the rest of the model diagram.

130

Laboratory work #6

Figure L45. Editing the name of the operation

Message Properties Now let's look at the properties of the newly introduced communication. When you call the SetTimer () => RClick => Detial we get into the dialog box shown in Figure L46.

Figure L46. Set properties posts 131

Laboratory works

Here we see two groups of radio buttons (radio buttons): 1. Synchroniztion – definesthe procedure for messaging and can be selected from the following options: – Simple – asimple message sending; – Synchronous – theoperation is performed only when the client sends a message to the server can accept the message client; – Balking – operation takes place only when the server is ready to immediately accept the message if the server is not ready to receive, the client does not issue a message; – Timeout – the customer refuses to issue a message if the server within a specified time can not accept it; – Asynchronous – the client displays a message, and, without waiting for the server's response, continues to implement its program code. For each type of transaction shooter posts varies in accordance with Fig.L47. 2.Frequency – determinesthe frequency of messaging: – Periodic – messagereceived from the client at specified intervals; – Periodic – messagereceived from the client regularly. The operation OnTimer () suitable installation Asynchronous and Periodic, because the class of the timer is the same as is done with his message to another class, and in our case, the Timer serves only controller class, but in a real system, you may need to call interrupt for multiple objects .

Figure L47. Various posts

Adding class rlantDayHour If you look at a chart created earlier states, after receiving the message from the timer going analysis of the time elapsed from the start of planting. This analysis is a good idea to pass on to the shoulders of a special class of object, such as a class rlantDayHour. This class will be responsible for counting the day and hour. Add object m_rlantDayHour and will create a new class rlantDayHour. Connect new posts UpdateTime () and GetCurrentTime () controller object and m_rlantDayHour and obtain Fig. L48.

132

Laboratory work #6

Figure L48. Adding objects m_rlantDayHour

The final version of the chart This is the process of visual design, the system is gaining in the process of adding detail charts and detailing interaction between them. Now that all the necessary opportunity to explore, you can add communication between the sensors and actuators. The beginning of this process is shown in Fig.L49.

Figure L49. Adding a chart of sensors and actuators

In this figure, added sensors, a heater and a fan. Add WaterTank, NutrientTank Light, and you can own.

133

Laboratory works

Laboratory work # 7 Chart cooperation Collaboration Appointment chart Second, the already mentioned type of interaction diagrams, – a Collaboration Diagram. With English, the term translates as «cooperation». Indeed, this chart is different from the previous one in that it does not focus on the sequence of messaging, it reflects the presence of relationships in general, that is reflected in this chart for messages from clients to servers. Because the timeline is not involved in the demonstration message, then this diagram is obtained compact and is perfectly suited to cast a single glance the interaction of objects. However, it should be understood that the diagram shows the interaction between objects, not classes, that is a snapshot of objects in a certain state. After all the objects created from a difference in the design phase of classes are created and destroyed throughout the work program. And every time there is a particular group of objects with which you are working. In this regard, there are concepts like the lifetime and scope of objects that will be discussed later. Create a chart Developers Rational Rose laid the convenient ability to create diagrams based on Sequence diagrams Collaboration and vice versa. And as the chart Sequence we already have, then we create on its basis Collaboration. For this, while in the chart, do the following: Menu: Browse => Create Collaboration Diagram. At the same time to create the desired chart type dialog box (Fig.L50) select the type of chart Collaboration. However, in this case creates an empty diagram already created objects are to be transferred. So for us, the first option is better suited.

Figure L50. Selection window creation Collaboration diagrams

There will be a diagram showing at first glance, piling icons. But once you have it, «stretch out» mouse, chart acquire quite readable form (Figure L51). In this diagram, the central Controller object and all messages coming to him or coming from it, which rightly reflects our understanding of the system. Interactions 134

Laboratory work #7

between the controller and the other devices are represented by lines with arrows added, similar to those depicted on Sequence Diagram. But it is easy to notice that all posts in one direction and are coming together as a signature to the same direction, so we get a complete picture of the interaction

Figure L51. Automatically created diagram Collaboration

Toolbar When you activate the chart line tool takes the following form (Fig.L52).

Figure L52. Collaboration Diagram Toolbar

Object Object allows you to create objects that have state, behavior and personality. Each object in the diagram shows an implementation of a certain class. Class Instance Class Instance allows you to add abstract implementation class diagram. What is the difference between an object and an abstract implementation class? If you add an icon on the chart externally, these icons are no different. The difference in their internal contents. The object involves setting its lifetime and other properties that are unique to a particular object. An abstract class implementation can not change these properties and is intended only to show the interaction. 135

Laboratory works

Object Link The interaction of objects is reflected by showing their relationships. The existence of ties between the two classes symbolizes the interaction between their implementations (objects created on the basis of these classes). Thus one object may send a message to another object. Link To Self Since objects can send messages themselves, this icon indicates that the object has a feedback from yourself. Link Message Link Message allows you to reflect the relationship, which implies mandatory reporting. Reverse Link Message Reverse Link Message allows you to reflect the relationship, which implies mandatory reporting in the previous paragraph, but in the opposite direction. Data Flow Data Flow allows you to reflect the relationship, indicating that data is being transferred from one object to another. Reverse Data Flow Like the previous icon allows you to reflect the relationship, indicating that data is being transferred from one object to another, but in the opposite direction. Creating an object Add to chart a new object m_WaterTank. The object menu After adding you can see what offers us the context menu (Fig. L53).

Figure L53. The object menu

Briefly list the possibilities offered through this menu. – Open Specification – editing specifications of the facility; 136

Laboratory work #7

– Edit Compartment activates the dialog box display more information about the object. The content of such information depends on the type of object; – Automatic Resize allows the automatic adjustment of the size of the object along the length of the text contained therein; – Show Concurrency enables display of this icon-type matching to create multithreaded programs. This type is defined in the class; – Show Persistence allows you to show on the diagram the lifetime of the facility; – Show Class allows you to show the name of the diagram class. Creating relationships between objects Connect the new object Controller object line Object Link. In order to show that the controller will arrive from the message, press the Link Message. Once the cursor takes the form of the cross, we point to the line. Beside her, an arrow appears the message for which you can enter the properties similar messages to Sequence Diagram, using the context menu. In order to show that the object m_WaterTank returns the data at the request of the controller IsON (if enabled) and IsOFF (if off), create a pointer to Reverse Data Flow. To do this, click in the following icon, and then the cursor will change to a cross, an arrow point to the messages, but not to the line Link Message. After filling out the properties of the message should have something like this (Fig.L54). Note the data is background information and shows us that at least one of the messages must return a value, processed by the controller

Figure L54. Note Data

Automatic transfer of data to the chart Sequence If you switch to the chart Sequence, you will see Fig.L55. This Rational Rose is automatically moved we have introduced changes to the chart Sequence, thereby 137

Laboratory works

freeing us from the monotonous work of transferring data from one chart to another. However, it is necessary to place the message in the correct order, which the program of course, does not know and have in mind that the order in which messages are entered, in the order they are executed.

Figure L55. Automatic filling Sequence Diagram

Setting the scope of the objects Each connection Link Message have the appropriate properties that allow you to customize the scope of related objects. To begin with let's deal with the concept of «scope». In all, even a small program, there may be variables and functions belonging to different classes and have the same name. In the case where the classes are written by different people who may have never seen each other, for example, using class libraries, it is difficult to achieve a unique name. Readers familiar with the programming language database FohRro, knows how difficult it is to find a minor mistake when you change a variable in the subroutine. For those who are not familiar with the language clarified that this language extends the scope of the definition of a variable and then. Thus, all the variables defined in the parent program can be seen as the default routines. It is convenient not to pass parameters. But imagine that in a cycle of the variable i is called the function, which is written by another programmer and also uses a loop to the variable i. In this case, the work program will be broken up, with unpredictable consequences. Fortunately, the C language is much more strictly related to the scope and variables defined in the subroutine or the selected block in the program, will be hidden from the changes in other parts of the program. However, you must take care of the transmission of these variables as parameters. 138

Laboratory work #7

When you create a class in C++ scope variables it is something intermediate between the two options described above. Variables defined as members of the class, it can be seen all methods as if they were defined globally, and at the same time, they can be hidden from the accidental or even intentional changes, if they are defined in the section private or protected. To set the scope, go to RClick => Open Specification and get into the dialog box shown in Fig. L56.

Figure L56. Setting the scope for the Link Message

To define the scope of the server object is a block Supplier visibility, client – Client visibility. In these blocks, the values are available for selection: – Unspecified – not specified, this value is assigned by default; – Field – the object is included in other object; – Parameters – the object parameter passed to another object; – Local – object locally defined within the boundaries of another object; – Global – object is global in relation to another object. If you change the scope at the end of the line appears connecting the box to the specified scope. You can also check the box indicating that the object is shared (Shared). Changing the properties of messages Bookmark Message (Fig. L57) allows you to change the properties of messages for the selected connection. And you can add methods directly from this window for both the client and the server. The figure shows a list box with the message context menu activated. 139

Laboratory works

However, we must remember that the addition of the methods in this window will not add them to the appropriate classes. On the one hand, it is not very convenient as it is necessary to add methods directly in the classroom, but it becomes a must if the methods inherited from the base class and add them to the child you are not going. Now you can add an object Light (light) and provide scope for other Link lines. It should look as follows (Fig. L58). Once again on the scope If you look closely, then for all objects except the timer, you can put the scope of Field, as to the Timer object is scope Global. It is not by accident. The scope of a specific object is determined by the design of the program structure and, in this case, all the objects are made in the object fields of the controller, and the timer will be external to the controller, so it is as a global point. Under the global object I mean an object created within a container object, which includes the controller. Such an object can be Application (application object), or you can create an object GreenHouse (Galicia), which describes the physical presence of our greenhouse of different devices, and all executive and measuring devices would include in this facility.

Figure L57. Access the message list

In the latter case it would be possible to use arrays of devices, so that the user can specify the number of specific control devices (including controllers) present in the greenhouse. But since the problem more training than practical, we use a class of minimal complexity and most illustrative. 140

Laboratory work #8

Figure L58. Summary Collaboration diagram

Laboratory work # 8 Chart Component Appointment chart Component Diagram (component diagram) allows you to create a natural reflection of the current model. The diagram shows the components of the organization and the relationship of software components provided in the source code, binary or executable file. Communication in this type of chart are based one component from each other and have a special display by the icon «dependence». Also, this type of chart allows you to get an idea of the behavior of the components of the interface are available. The interface shows the interaction of the components, and although the interface icons belong to a logical representation of the system, they may be present and chart components. The current model can create several diagrams to reflect the components of containers, components or a top-level description of the contents of each container components. In the latter case, the component diagram belongs to the container, for which the content is reflected. Notes on creating diagrams of components It will be somewhat premature to create a full diagram of the control system components greenhouse farming, because not yet identified all the links and structure of class inheritance. However, for a small system, which is a hothouse, consisting of a single executable file, the development of such a diagram is not at all appropriate. But in order to become familiar with the capabilities of the chart components and not be 141

Laboratory works

distracted by it in the future, it is proposed to complete the preliminary design of this particular chart. Only preliminary, because life is difficult any rules. There are strategic and tactical decisions that sometimes contradict each other. Throughout the design of the system, up to the finished product software in the diagram will be modified. We do not fully reflect the iterative process, so some taken during the design of the solution may not coincide with those obtained at the end of the code. This is normal. During development, you simply need to reflect these changes to the previously created charts that you can do yourself. In the meantime, create a chart component for only a few classes to get some practice with this type of chart. In Rational Rose laid a great opportunity to work with the software libraries. And it is possible how to develop the library and use the ready-made. It is only necessary to specify which classes in which components are located. In the development of a software project division of classes for components is a major challenge. In order to ensure minimum effort to develop and support, closely related classes are collected in the library DLL, OCX, etc. This usually involved systems analysts who design the structure of the software, Rational Rose offers all possibilities for this design. Create a chart component To create a chart using the menu Browse => Component Diagram or use the icon on the toolbar. This will be activated selection dialog box diagram, by which the user can create, delete, rename the chart. Toolbar When you activate the chart line tool takes the following form (Fig.L59).

Figure L59. Строка инструментов Component диаграммы

Component Icon Component allows you to show the creation of the component. A component is a software module, such as source code, binary, executable, dynamic link libraries, etc. Interaction of the diagram represented by one or more icons interface. The components can also be used to show the relationship of modules at compile time or runtime, as well as to show which classes are used to create specific components. Due to the fact that the system can consist of different types of modules, the user can use these patterns to determine the difference, the variation of the stereotype often leads to a change in the graphical display of the component on the diagram. Typically, the component name matches the name of the file representing the component and each component must be assigned to the programming language. 142

Laboratory work #8

Package Icon Package allows you to display a container which comprises a group of components in the model. Dependence The user can establish communication between the components of this type, which are depicted as a dotted arrow from one component to another. This type of relationships that a class contained in a container a client inherited contain elements used, or in any other manner depends on the class, which is exported from the server component. The user can display the communication interface component, and other components, and this means that the client component uses the operation of other components (Fig. L60). If in this case the connection will be directed in the opposite direction, it means that the client component provides transaction server component.

Figure L60. Example of the Operations component

Main program Icon Main program allows you to add the component model, indicating the main program. for tasks that are created in the object-oriented environment Visual Studio, the main program library MFS is hidden, and the application starts with the creation of the main application class theApp, which is inherited from the library class CWinApp, so this icon is rarely used. Subprogram body Subprogram body icon lets you add a component to the model, indicating the body of the subroutine, and is also used for non-object-oriented components. Package specification / body Icons Package specification / body allows the container definition display (Package specification) and a description of the container (Package body), which are usually linked. For C ++ Package specification- this header file with the extension .h, and Package body- a file with the extension .cpp. Task specification / body Icons Task specification / body display allow independent threads in a multithreaded system. If such tasks are compiled independently of the conventional modules, it is possible to place classes and their definitions in such tasks. 143

Laboratory works

Component Properties For the previously described class EnvironmentalController create icon Package specification. Thus, we show that the definition of the class will be in the file EnvironmentalController.h. Tab General (primary) After you create an element, go to the General tab of its specifications using RClick => Specification => General, and fill it out as shown in Fig.L61.

Figure L61. General tab component specifications

Here, the user can adjust the component name (Name), is a list of stereotypes (Stereotype), available for selection, as well as other elements, it is possible to fill in the documentation (Documentation). Also offers a choice of programming language for the component. Due to the fact that we create a system of governance greenhouse farming in Visual C++, you need to install the language, proposed changing the default value of Analysis, the value of VC++. After that, the next window will activate this tab VC++, and COM. COM tab COM tab is designed to set the properties of COM objects (Fig.L62). It lists the properties of an object that can be changed. Briefly list these properties: – Generate establishes the need for generation; – filename sets the full path to the component; – library sets the name of the library, for example, stdole; – uuid set identifier for a COM object; – version sets the version of the component; – helpstring sets the string that is used to describe the component; – helpfile sets the name of the file that contains the reference system for the component; – helpcontext sets topic ID reference describing the component and located in the file specified as the helpfile; 144

Laboratory work #8

– lcid sets the locale identifier; – attributes sets the attributes that further define the COM component or a class, for example, control, hidden, restricted, licensed, appobject, nonextensible or oleautomation.

Figure L62. Tab COM component specifications

Tab FC++, Tab VC++ is designed to display the object properties associated with the VC ++ language, but, according to the embedded documents, these properties are not designed for installation by the user. Detail tab Tab Detail (detail) shows the description of the definitions for the component, such as the class name, and other design variables, depending on the specific implementation of the programming language. Realizes tab Realizes tab allows you to show the specifications of the component included in the component classes, as well as to include or exclude these classes from the component, and the classes included in the components are marked with (Fig. L63). Check box Show all classes (show all classes) allows you to show only included in the component class or all the classes and models available, for example, for further inclusion in the component. Files tab On the Files list contains files or URL, which are attached or added to the component. This feature is used to manage links to additional documents that indicate information on the generation of a system or component. From this screen is possible to open and view the related documents by double-clicking the mouse on the line of the document, or from the context menu. 145

Laboratory works

Figure L63. Realizes component specifications tab

Create a chart Now create a mapping of other components associated with the controller. Create icons sensors and devices. Connect icons Dependency relationships so as to show that the header file header files required controller and sensors, which in turn are used to compile the files themselves sensors and devices as shown in Fig.L64.

Figure L64. Chart Component 146

Laboratory work #9

Laboratory work # 9 Features class diagrams Appointment chart Class diagram (class diagram) – thebasic diagram to create the application code. With the class diagram created by the internal structure of the system, described by inheritance, and the relative position of classes relative to each other. It describes the logical view of the system. This is logical, since classes – itis only the workpiece to create an object on which will then provide the physical objects. Thus, the class diagram describes the overall performance of the system and is opposite Collaboration diagram, which presents the objects in the system. However, this division is not strict rule and perhaps a mixed representation of classes and objects. The class diagram is used not only to create a logical representation of the system, Rational Rose enables to create class diagrams based on source code. And as the description of the classes created in the language of UML, on the chart created in the same style, the ability to generate source code in any programming language, which is supported by the code generator Rational Rose. Typically, a class diagram is created for all classes of systems, in contrast to the diagram objects that designers create for the individual objects with complex behavior and interactions. The class diagram contains icons representing the classes, interfaces, and their relationships. Classes can be any C++ classes: simple, parameterized or metaclasses. Interfaces – isa set of actions or operations that serves the implementation of the class interaction. Possible to create one or more class diagrams which describe the top-level classes in the current model. It is also possible to create one or more class diagrams which describe classes contained in containers. For example, the class diagram itself is the container for the model classes, but you can allocate additional containers for logical grouping of classes. Through the class diagram can be changed at any time, the properties of any class or bonds, and at the same diagram or specifications related to the variable class, will be automatically updated. The class diagram can be used as the analysis of the finished system, and the development of a new one. Create a chart Main class diagram (Main) is already present in a newly created empty model, but it is possible to create additional diagrams using familiar methods through the context menu in the Local View Browse, using the Browse item in the main menu or by pressing the button. Toolbar When you activate the chart line tool takes the following form (Fig. L65).

Figure L65. Toolbar for class diagrams 147

Laboratory works

Class (Class) This tool allows you to create a new class in the diagram and model. The concept of class in the Rational Rose is similar to the concept of class in C++. Class - is the installation of the structure and pattern of behavior for some set of real objects that will later be identified in the program based on this template. Class – isan abstraction, the real world. When this abstraction takes concrete embodiment, it is called an object. For the detail behaviors classes are state diagrams and actions discussed above. Class in UML notation is depicted as a rectangle divided into 3 parts (Fig.L66). At the top of the class name is written in the mid – attributes at the bottom – theoperation.

Figure L66. Image class

Interface (interface) Icon Interface Interface creates an object, which points to the externally visible operation class or component. Usually an interface is created only for certain welldefined classes or components and is designed more for the logical mapping system, but may be present at both the class diagram and the chart components. In the class diagram Interface is normally displayed as an icon of class with the stereotype «interface». Unidirectional Association (unidirectional communication) Icon Unidirectional Association to create a one-way communication with a class or a class of class interface. This is a common and weakest form of communication. Association Class (Class Association) Association Class icon allows you to associate the class of associative bond. This property is preserved in the class, and to install it, you need to create a class and class correlations to associate with others with this icon. Package (container) The icon allows you to create an element that is used to group elements. It can be used for physical or logical groupings. In this case, the container more convenient to use for the physical grouping code. But for a small system, which is a hothouse, we do not use containers. created class diagram Dependence of instantiates (implementation dependent) Dependence of instantiates icon allows you to create a link Dependence of instantiates, while the code generator ++ Rational Rose generates the class code, 148

Laboratory work #9

including the definition of a dependent class by generating directive #include. This type of installation connections indicates that another class using the class as a parameter in one of the methods. Generalization (generalization) Generalization icon allows you to create a relationship Generalization, for which Rational Rose generates code inheritance, that is, create a subclass of compounds in this connection class inherited from the parent class. Realize (perform) Realize icon allows you to create a link between a class and Realize interface or between the component and interface. This type of communication is used to show that the class performs provided interface. Putting class diagram To create a new class and put it in the class diagram, you can use the appropriate icon from the tool bar or menu Menu => Tools => Sreate => Slass. We have already created some classes of systems, but do not put them on the chart. To place an already created a class, for example, EnvironmentalController on a class diagram, there are several ways: – drag the desired class of the mouse out of the window Browse; – use the Menu => Jquery => Add Classes and in the dialog box (Fig. L67) to choose the necessary classes to be included in the chart.

Figure L67. Adding created class diagram

The first method is fast, but not suitable for all charts. But if you want to include in the chart a few existing classes, the second method is definitely better. The concept of «stereotype» class We have already met with the notion of stereotype in other diagrams, class diagrams but need to be more detailed discussion of this concept. The stereotype allows you to specify additional features to develop models that are not supported by the language of UML. The concept of stereotype makes it easier 149

Laboratory works

to add information to the new elements of the model by selecting the stereotype for these elements from an already defined and is an additional classification elements. Some patterns are already defined in the Rational Rose, but you can always add a new user patterns, which are stored in a file stereotypes. As an example one can cite the following patterns. You can use classes that are designed for data storage, the stereotype «Storage», for the classes that are designed to display data - the stereotype «View», for classes that allow the user to monitor the implementation of the program «Controller». The stereotype can be shown or hidden for the class using the context menu item Options class. In Fig. L68 shows an example of a variety of visualization options stereotypes. From left to right: None, Label, Decoration, Icon. To demonstrate in the preceding example uses the built stereotype Actor. In Rational Rose provides the following built-in stereotypes: – Actor; – boundary; – business actor; – business entity; – business worker; – control; – entity; – Interface.

Figure L68. Demonstration of a variety of visualization options stereotypes

The need is particularly felt in stereotypes using diagrams Use Case, the development of which ensures that the system will be exactly what the thought of the user, but also in the class diagram stereotypes can be used for more detailed description of classes. Context Menu class After adding the class to the diagram context menu becomes available class. The content of the menu can be changed by the class association with different programming languages. Menu items related to the programming language VC ++ we'll see later, and now a look at the menu options for the class and is not associated with any programming language (Fig.L69). Here are the appointment of the individual items: – Open Specifications – openingthe dialog box fill in the specifications; – Sub Diagrams – allowsyou to create a class diagram for the current activity and conditions, or to go to class diagram; – New Attribute – allowsyou to add a new class attribute; – New Operation – allowsyou to add a new operation for the class; 150

Laboratory work #9

– – – –

Select In Browser – allowsyou to select a class in the window; Relocate – allowsyou to move into a new class of container or in the location; Options – callsettings submenu icon class; Format – thecall settings submenu font colors, fill the chart.

Figure L69. Context Menu

Menu Options (Properties) Options menu let you control the display of the class in the class diagram consists of the following items: – Automatic Resize – automaticallyadjusts the size of the icon in order to accommodate all of the entered text names, attribute or operation. This feature is useful for the initial filling of the names of attributes and operations, and is enabled by default. In the future, when the class is already linked to others and takes its place in the class diagram, it can be turned off; – Stereotype Display – allowsyou to show or hide the stereotype for the class; – Show Visibility – allowsou to show the type of access for operators and attributes, such as Public, Protected, Private, Implementation. – Show All Attributes – Showsor hides the attributes of a class; – Show All Operations – showsor hides all the operations of class; – Show Operation Signature – shows or hides the signature of the so-called operation, ie parameters and return value; – Show Compartment Stereotypes – This setting allows you to show or hide the name of the stereotype to the operation or class attribute; – Select Compartment Items allows you to activate a window or select items Operations attribute to display, in the event that you want to hide, not all the attributes or operations, but only some. To do this, you must activate a window Select Compartment Items and select to display the necessary attributes and operations (Fig.L70); 151

Laboratory works

At the same time from the left side of the window, where there are all the details you need to move to the right, only those that are needed to display, then click OK.

Figure L70. Installation required to display the attributes and operations

– Suppress Attributes allows you to hide all the attributes, even if they have been selected with the help of the window Select Compartment Items. This point is interesting in that when it is selected not only to hide the attributes, but also closes the menu item Attributes, which does not allow to introduce new; – Suppress Operations allows you to hide all the operations similar to the attributes in the preceding paragraph.

Laboratory work # 10 Class Specifications Rational Rose allows you to install a significant amount of class properties, which, in particular, affect the class code generation, so to better focus for further action, analyze tab window specifications. Perhaps, the controller parameters of the medium you already rather tired, so to parse the specification take the class temperature sensor –TemperatureSensor. Tab General (primary) When choosing from the context menu item temperature sensor Open Specification dialog box shown in Fig.L71. Specifications class have several tabs, and the first tab is activated General (main). This window allows you to define the main properties of the class, such as its name, type, define the stereotype of class and access to it, when the class is in the container. As in all other charts, you can specify the documentation to the class. Here are the fields that are on this tab: – Name is used to set the class name; – Type is intended to specify the type of class. In our case - is «class», but you can select «metaclass», «parameterized class», etc .; – Stereotype sets the stereotype of the class; 152

Laboratory work #10

– Export Control for determining access to the class when it is located in the container This Public specifies that the element visible outside of the container in which it is defined and can be imported into other parts of the generated model; Protected – itemis available only for nested classes, classes with friends and actually type in a class; Private is a protected member of the class; Implementation – elementis only visible container as defined.

Figure L71. General tab specifications temperature sensor

Tab Detail (detail) Detail tab allows you to specify advanced settings of class, such as the expected number of objects created by the class, the expected consumption of RAM, etc. (Fig. L72). Here are the fields that are on this tab: – Multiplicity (multiplicity) allows you to specify the expected number of objects that will be created based on this class. Normally, this setting is convenient to ask for related classes; – Space shows the amount of memory required to create an object of this class. The field can be specified directly or the formula that describes the memory requirements and value must take into account the overhead of object creation, plus the size of all the objects included in this; – Persistence determines the lifetime of the object class. If you check Persistence, the object must be available throughout the program, or to access other threads or processes; – Concurrency refers to the behavior of an element in a multi-threaded environment. Set this field in the transaction must not conflict with 153

Laboratory works

the installation in the classroom. This setting can have the following options: 1. Sequential (default) – workingclass is only guaranteed for one stream. Only one thread may be started using the methods of the class at a time; 2. Guarded – classdesigned to work with multiple streams. This class provides the interface between the flows – toachieve a consistent work flow is the arbiter streams, providing a specific job flow at any given time; 3. Active – classis a class separate stream; 4. Synchronous – class provides several work streams, synchronizing them. – Abstract adornment means that the class is abstract, ie, base class that must be inherited by subclasses, and without this inheritance does not make sense. Also in the class can be defined abstract operations, which represent a template for creating transactions in classes that inherit from this, and do not perform any action. – Format Arguments used only for parameterized classes and utility classes. For ordinary grades, this field is unavailable.

Figure L72. Detail tab specifications temperature sensor

Tab Components (components) Components tab reflects components with which the associated class (Fig. L73). On the red labeled marker components which are included in the current model, and can be shown other components of the model. If you have not shown a component MFC 6.0, it is necessary to include, or check Show all components, or has not been imported library MFS. From this tab by double-clicking on the component, you can get access to its specifications. 154

Laboratory work #10

Figure L73. Components Tab specifications temperature sensor

Tab Attributes (attributes) This tab allows you to add, delete, edit the attributes of a class (Fig. L74)

Figure L74. Attributes tab specifications temperature sensor 155

Laboratory works

On this tab is a list of class attributes that can be edited using the context menu. Show inherited check box lets you hide or show the available attributes of the parent class. To add an attribute, it is necessary from the context menu, select Insert. By double-clicking on an attribute, or from the context menu Rational Rose provides access to the dialog box attribute specifications (Fig.L75). Here the user can change the name attribute (Name), its type (Type), and stereotype (Stereotype) set the initial value (Initial value) and access type attribute (Export Control).

Figure L75. General tab attribute specifications Class

Additional Detail tab attribute specifications Class (Fig.L76) allows you to specify the type of storage attribute in the class: – By Value – by value; – By Reference – the link; – Unspecified – not specified. The user can also specify that the attribute is Static (static) or Derived (derivatives). Tab Operations (operations) Operations tab allows you to add, delete, edit operation class (Fig.L77). This tab lists the operations of the class that can be. Edit using the context menu. To add operation is necessary in the context menu select Insert. By double-clicking on the transaction or from the context menu Rational Rose provides access to the dialog transaction specifications. Detail tab allows you to set the specifications of operations additional properties of the operation (Fig. L78). 156

Laboratory work #10

Here are the fields shown in this tab: – Arguments (arguments) allows you to set a list of arguments for the operation of their types and defaults; – Protocol (Protocol) allows you to specify a list of plants that is provided to the customer for the call; – Qualification (qualification) allows the identification of language-dependent features that allow qualified method. This qualification is necessary if you use the Common Lisp Object System (SLOS); – Exceptions (exclusions) allows you to specify a list of exceptions that may be caused by surgery. Here you must enter the name of one or more classes that handle exceptional conditions; – Size (size) allows you to set the amount of memory required to perform the operation; – Time (time) allows you to set the time of the operation; – Concurrency (competition) for multithreaded program reflects the type of operation:

Figure L76. Detail tab attribute specifications Class

1. Sequential (default) – Onlyone thread must run at the same time; 2. Guarded – possibleto perform multi-stream controlled by a class; 3. Synchronous – operations can be done in parallel. The user can set a competition for the implementation of a class in the class specification. This field is unavailable for editing utility classes, parameterized classes, and implementations of the utilities classes. Tabs Preconditions, Postconditions, Semantics, allow you to specify an additional description of the processes of preparation and completion of the operation, as well as 157

Laboratory works

the operation of the algorithm. In addition to the text description Here you can specify the name of the Interaction diagram that describes these steps.

Figure L77. Tab Operations Specification class attributes

Figure L78. Detail tab operations specifications 158

Laboratory work #10

Tab Relations (Communications) Relations tab to add, delete, edit communication class (Fig.L79). On this tab is a list of links of the class that can be edited using the context menu. To add a connection is best to use the appropriate tool from the tool bar and to remove – shortcut menu. VC++, Tab Tab VC++, which came after the association class in Visual C++ is designed to change properties associated with this class. The fields of this tab are not designed for editing, so we will not consider them. Tab COM COM tab allows you to set the properties for the classes that are designed to create the COM objects in the model. If such objects are imported into the model, they also arises tab (Fig. L80). – Generate – a property that determines whether the generation of source code class; – kind – a property that identifies the type of object that can be as follows: coclass, enum, record, module, interface, dispinterface, alias, union, max; – uuid – a property that specifies the identifier string for the class or library that identifies the COM object in the system;

Figure L79. Relations tab specifications Class

– version – versionof the COM object; – helpstring, helpcontext intended to set the identifier string and a help file for the object; 159

Laboratory works

– attributes – setssuch attributes to the object as a control, hidden, restricted, licensed, appobject, nonextensible or oleutomation; – dllname – specifiesthe filename DLL, in which the facility is located; – alias – specifiesthe type for which you create an alias.

Figure L80. Tab COM specification class

Laboratory work # 11 Links Purpose and types of connections Classes are rarely isolated, they often enter into relationships with each other. These relationships are shown using various types of connections. The types of relationships affect resulting in the generation of graphs based on the source code, so you need to consider the details and specifications of communication. In the class diagram, the following types of links: – unidirectional association (unidirectional association); – dependency (addiction); – association class (associated class); – generalization (inheritance); – realization (implementation). Unidirectional Association One of the most important and complex types of communications used in the class diagram. This relationship indicates that one class is included in the other as an attribute, by reference or by value (Fig. L81). 160

Laboratory work #11

Figure L81. Example of communication Unidirectional Association

The following listing shows the C++ code that was generated for connection shown in Fig. class Class2; class Class1 {public: Class2*theClass2; }; Rational Rose generates the class code according to the specifications established connection, so consider the effect of various settings on the specifications of the code received. When you right-click on the connection activates a context menu that provides quick access to the settings link. However, specification of communication allow to do the same with the help of tabs dialogs. Activate the specifications using the context menu or by double-clicking the arrow on the association, with the General tab open specifications (Fig. L82).

Figure L82. General tab specifications Unidirectional Association

The General tab Displays information about the name, stereotype, the parent class other basic information about the connection.

161

Laboratory works

– Name (name) specifies the name of the connection. Each connection can be, though not necessarily given a name that a word or phrase indicating the purpose of the whole, or the semantics of the communication; – Parent (Parent) specifies the name of the container, which holds a bond; – Stereotype (stereotype) indicating the stereotype; – Role A / Role B specifies the name of the role to which one class is associated with another; – Element A / Element B specifies the name of the class that is associated with this role. Detail tab Detail tab specifies additional communication properties (Fig. L83).

Figure L83. Detail tab specifications Unidirectional Association

– Link Element associated class specifies if the link is connected to it by the Association; – Name indicates the name of the associated class; – Constraints expression indicates a semantic conditions which must be met, while the system is in a stable condition. Role General tab Role General tab displays the settings of the variable that will be included in the class (Fig. L84). Since the direction of communication in our example from Class1 to Class2, we will fill the tab Role And General. This tab has the following fields: – Role allows you to specify the name of the class variable; – Element displays the name of the class for which the variable is created; – Export Control determines the access to this element. In this case, set the switch Public, so the variable was created in the section Public. 162

Laboratory work #11

Figure L84. Role General tab specifications Unidirectional Association

Role Detail tab Role Detail tab details the installation of communication (Fig. L85).

Figure 85. Role Detail tab and the specification Unidirectional Association

Here are the following fields: – Role allows you to specify the name of the class variable; – Element has the class name to which the variable is created; 163

Laboratory works

– Constraints expression indicates a semantic conditions which must be met, while the system is in a stable condition. When you set limits, it will be shown in the diagram in braces. And on the generated code, this restriction will not be reflected. – Multiplicity shows how much is expected to create objects of this class can be defined by a number or letter «n». The value «n» indicates that the number is not limited. You can specify various options for the expected number or range. Hiding, the number displayed next to the arrow communication; – Navigable shows the direction in which the connection is valid. When checked, the connection takes the form of an arrow indicating the direction of communication. This field has a direct impact on the generated code for the class, since a class will focus arrow communications, he will be included in the other. In order to change the direction of communication, uncheck the box to Role A Detail tab and set it in the tab Role B Detail. In the case of code lifted boxes on both tabs of any one element will not be included in the other. This diagram will show a simple line; – Aggregate shows that one class can not simply use and contains another. However, be careful to show that the class Class2 is in the class Class1, you must select this option in the tab Role B Detail. In this regard, the arrow in the diagram acquires diamond back side of the arrow (Fig. L86).

Figure L86. An example of the aggregation class

Aggregation is a physical switch associated class in another class. This code generator With C++ Rational Rose generates the code shown in Listing. Class Class2; Class Class1 {public: Class2 theClass2; }; – Static means that the props - common to all objects of that class. Moreover, after initialization it can be accessed, even if there was not created any object class. Static applied to the variables of this type are not duplicated when you create a new object class. For example, if you want to know exactly how many objects of the class is created, it can be charged to the class monitor this number, it created a variable of type static int iCnt, visible in all objects of the class; – Friend determines that the specified class is a friendly class that is has access to a protected class methods and attributes. – Key / Qualifiers attribute that uniquely identifies a single object. In the code generation is not affected. 164

Laboratory work #11

Association Class (associated class) Use this type of connection to display the association property. The properties are stored in a class and connect coupling Association (Fig. L87). This type of connection does not have its specifications.

Figure L87. Example of the Association Class

Dependency of instanties (dependence) This type of connection allows you to show that one class uses another object. The use can be carried out in the transmission parameters, or call class operations. In this case, the code generator C++ Rational Rose includes a header file in the class that uses the operators or objects of another class. Graphically, this type of communication is reflected by the dashed arrow (Fig.L88).

Figure L88. Example connection Dependency of instanties

Generalization This type of connection allows you to specify that one class is a parent of another, in this case the code will create a class inheritance. An example of such a connection is shown in Fig. L89.

Figure L89. Example connection Generalization

165

Laboratory works

The following is a listing obtained by the code generation for the example shown #include “Class1.h” class Class2: public Class1 { }; Further work will use two types of connections - is Unidirectional Association, to aggregate the inclusion of references to classes and Generalization, to create an inheritance hierarchy.

Laboratory work # 12 Writing code in C++ Introductory remarks On the basis of Rational Rose class diagram allows you to create the class code in the selected language. To take advantage of this opportunity, you must make sure that the selected language is set using the Add-Ins Manager. Previously, we studied the resulting class code after changing the settings of a class diagram. We'll see how it is necessary to change the specifications, in order to get some code, that is, we will initially come from the class code, and consider the necessary steps to obtain it. You have to understand that the actions that are necessary to create the code in one programming language, probably not suitable for use with other languages. Therefore, we first analyze the option of establishing a universal code in C++, regardless of the compiler. Reference class code Back to our greenhouse and remember that the sensors in the greenhouse can be a little, and therefore need accurate positioning of the sensor. Using the number. In fact, to determine the position coordinates of the sensor can be used, which will help us to bring the testimony of a particular sensor on the display, but is using only a number. To set your current location will be used type Location, and for the temperature the type Temperature. Let us assume that we want to get the following code in C++: // Temperature Celsius typedef float Temperature; // Number that uniquely identifies the position of the sensor typedef unsigned Location; class TemperatureSensor { public: TemperatureSensor(Location); _ TemperatureSensor(): void calibrate (Temperature actual Temperature); Temperature currentTemperature() const; }; For objects created in the program, or as they are called – the implementation of the class, convenient to use aliases simple types, for example, Temperature or 166

Laboratory work #12

Location instead of unsigned int. Thus, we can describe the language of abstraction derived domain. The constructor is passed the location of the sensor, it is possible to obtain calibration and temperature measurement. Association class with the language C++ In Rational Rose default all types are defined as classes. Therefore, we will create two new classes: Location and Temperature. for each of them, do the following: We choose a class, and then Menu: Tools => C++ => Code Generation. The dialog box shown in Fig. L90. It is necessary to choose the class that is assigned to the programming language, and click Assing (designate).

Figure L90. Assigning a class C ++ programming language

View the class code After generating code from the context menu available additional item – C++, where you can view the file header (Header) .h file and the class body (Vodu) .cpp, as shown in Fig. L91. Now you can view the files of the body class and header file after each modification, to see how these changes will affect the resulting code. Set the type of object Now the newly menu that appears choose Open Specification => C++ => Implementation Type => Override Value column then fill unsigned int. It should look as shown in Fig. L92. Do the same with the class Temperature, just do not forget to install a float and run the code generation RClick = C++ => Code Generation. Look at the title and you'll see what happened exactly what ordered. Now we can use the derived types for the class temperature sensor. 167

Laboratory works

Figure L91. Affordable menu C ++

Adding new operations Select TemperatureSensor => RClick => New Operation and enter the name of calibrate (actualTemperature: Temperature): void. We note that in contrast to the semantics of the C ++ language, is first specified variable, and then, after the colon, its type, and is similar to the return value is specified after a colon operation. To the left of the operation icon appears, if selected, it opens a set of icons that represent the available operations, respectively: public, protected, private, and implementation. In the latter case, if an item is defined in the container, it will only be visible for objects defined in this container. Similarly, add a constructor and receive operation temperature.

Figure L92. Filling properties of Implementation Type

168

Laboratory work #12

Installation according to classes In our case, the classes used to communicate a compilation dependency, which means that the temperature sensor in the class definition to include the required types. In order to show that the class of temperature sensor types must be used the Location and Temperature, use the link Dependency, why choose its icon from the tool bar. We click on it and then click on the class TemperatureSensor and hold the mouse button, drag the line to Class Location. Similarly, the class Temperature. When generating source code, in this case Rational Rose will automatically include the files and location.h temperature.h in the header file TemperatureSensor. You should have a view similar to Fig. L93. Now for the created class, you can start generating source code and compare it with what we need. Lapping received code If you look at the file header, we can see, what happened is not quite what you need. Here is the file without some official information, which includes a code generator class. All official information is inserted as a comment and has no effect on the subsequent generation of the executable file. #include “Location.h” #include “Temperature.h” // The temperature sensor measures the temperature in the greenhouse in Celsius class TemperatureSensor { public: //##Constructors(generated) TemperatureSensor(); TemperatureSensor(const TemperatureSensor&right); //##Constructors(specified) TemperatureSensor(Location Location); //##Destructor(generated) _ TemperatureSensor(): //## Other Operations(specified) void calibrate (Temperature actual Temperature); Temperature currentTemperature(); }

Figure L93. Dependencies class Temperature Sensor 169

Laboratory works

Here we see that in the code include the header file definition data and comments (this was Field filled RClick => Open Specification => Documentation). However, designers in the class for three, two and one is automatically created, which we have identified. And it is not enough official word const in operation currentTemperature. Correct this discrepancy. First, remove the automatically generated class constructors: Wind: Class Diagram => TemperatureSensor => RClick => Open Specification => C++ => Generate Default Constructor => DoNotDeclare and there Generate Copy Constructor = = DoNotDeclare. We pose the type of const: Wind: Browser + Logical View + TemperatureSensor => currentTemperature => C++ => Operation Is Const = True. Check the resulting source code and make sure everything worked as it should. Setting the properties of C++ So far, we have done all these actions without detailed explanations to show the possibilities of Rational Rose to create application code in C++. in order to enable you to use the features of C++, further describe the purpose of these properties, the list of which is available in the tab C++ class specification. – CodeName sets the class name in the generated code. This property should be set only if the class name should be different from the name given to the model of Rational Rose. This property must be used to create a usable C++ code, if a class in the model used Russian names. – ImplementationType allows simple types instead of defining a class that is installed by default Rational Rose. When setting this option creates a directive typedef. – ClassKey is used to specify the type of the class, such as class, struct or union. If the type is not specified, the class is created. – GenerateEmptyRegion – propertyspecifies how will create an empty partition protected: None – empty section will not be created; Preserved – emptypartition is created, if it is determined the property preserve-yes; Unpreserved – emptypartition is created, if it is determined the property preserve-no; All – willalways be created. – PutBodiesInSpec if set to True, the fall in the header file and a description of the class body. It used to compilers, which is necessary to define the class template for each source file. – GenerateDefaultConstructor allows you to set whether you want to create a constructor for a class by default. It can take the following values: DeclareAndDefine – createsa definition for the constructor and the skeleton in the body of the class constructor; Declare Only – createsonly the definition; DoNotDeclare – notcreated any definition or skeleton constructor. – DefaultConstructorVisibility sets section, which will be determined by the default constructor: public, protected, private, implementation. – InlineDefaultConstructor determines whether the default constructor is created as inline substitution. – ExplicitDefaultConstructor sets the default constructor as the explicit (explicit). – GeneralCopyConstructor determines whether the created copy constructor. – CopyConstructorVisibility sets section, which creates a copy constructor. 170

Laboratory work #12

– InlineCopyConstructor determines whether the copy constructor created as inline substitution. – ExplicitCopyConstructor stipulates that the copy constructor will be created explicit (clearly defined). – GenerateDestructor determines whether to generate the destructor for the class. – DestructorVisibility sets section, where you will create a destructor. – DestructorKind sets views created destructor: Common – normal, Virtual – virtual, Abstract – Abstract. – InlineDestructor determines whether a destructor created as inline substitution. – GenerateAssigmentOperation determines whether to generate the function override the assignment operator (=). – AssigmentVisibility defines a section where you will create a function of the assignment operator. – The AssigmentKind function determines the type of an assignment statement: Common - a common, Virtual - virtual, Abstract - Abstract, Friend - friendly. – InlineAssigmentOperation determines whether an assignment operator created as inline. – GenerateEqualityOperations determines whether overridden equality comparison operators (= and! =). – EqualityVisibility defines a section in which will be placed on the equality comparison operators. – EqualityKind determines the form of the functions of comparison operators for equality: Common – a common, Virtual – virtual, Abstract – Abstract, Friend - friendly. – InlineEqualityOperations determine whether the functions of comparison operators equality created as inline. – GenerateRelationalOperations determines whether to override the comparison operators ( =). – RelationalVisibility defines a section in which we will place the comparison operators. – RelationalKind determines the form of the functions of comparison operators: Common – a common, Virtual – virtual, Abstract – Abstract, Friend – friendly. – InlineRelationalOperations determines whether the comparison operators function created as inline substitution. – GenerateStorageMgmtOperations determines whether to override the new and delete operators in the class. – StorageMgmtVisibility defines a section in which we will place the operators new and delete. – InlineStorageMgmtOperations determines whether the new and delete operators are defined as inline substitution. – GenerateSubscriptOperations determines whether overridden operator []. – SubscriptVisibility determines the section to be placed in the [] operator. – SubscriptKind determines the form of the operator []: Common – a common, Virtual – virtual, Abstract – Abstract. – SubscriptResultType expression determines the return type of the operator []. 171

Laboratory works

– InlineSubscriptOperation determines whether the operator [] defined as inline substitution. – GenerateDereferenceOperation determines whether the overridden operator *. – DereferenceVisibility defines a section in which is placed the * operator. – DereferenceKind determines the form of the operator *: Common – a common, Virtual – virtual, Abstract – Abstract. – DereferenceResultType determines the return type of the expression for the operator *. – InlineDereferenceOperation determines whether the operator * is defined as inline substitution. – GenerateIndirectionOperation determines whether the overridden operator ->. – IndirectionVisibility determines the section to be placed in the -> operator. – IndirectionKind determines the form of the operator: Common - a common, Virtual – virtual, Abstract – Abstract. – IndirectionResultType determines the return type of the expression for the operator -> – InlineIndirectionOperation determines whether the operator -> is defined as inline substitution. – GenerateStreamOperations determines whether streams overridden operators (>). – StreamVisibilityopredelyaet section, which will be placed operators streams. – InlineStreamOperations determines whether operators streams are defined as inline substitution.

Laboratory work # 13 Creating a class code to Microsoft Visual C ++ Introductory remarks We got acquainted with the possibilities of creating a class code in C++, an abstract from a particular compiler. As usual, the approach is more versatile, and more difficult to create the necessary code has to handle a large number of installations. A simpler way to create an application to use the possibility of Rational Rose create a class code based class library firm Microsoft - MFS. It is not necessary to manually operate a significant number of installations have been built in the package module Model Assistant, which allows all the necessary setting through visual means. Ability to create the class code Class in Rational Rose – a description of the general structure (data links) to further the creation of objects. to generator Rational Rose was able to create on the basis of the model described program code for each class must specify the language for which you will create the code. It is also necessary to determine the component in which the class will be stored. If the language code is specified for creating VC++ user gets access to the entire class hierarchy library MFS using visual aids Model Assistant. When you create a class you must specify a stereotype that affects derived class's source code. So, if you change the stereotype on struct or union, will create the specified data types. 172

Laboratory work #13

As you can see, Rational Rose supports the usual classes C++ notation scope, such as public, private, protected. Thus, each attribute or operation in the specification of classes when creating the header file class will be defined in a section of the public, private, or protected. It is also possible not to create program code for a class definition. The structure of the generated code class For each class created by Rational Rose generates the following code structure: – directives include, which are based on the need to include attributes and relationships of classes; – class declaration, the class name, type, inheritance; – Variable Data members, which are created by the description class attributes and relationships; – Declaration of class methods and the skeleton of these methods for further filling of each transaction, specified in the description of the class; – documentation for each generated class variables and methods defined in the description of the model; – ID of the model that is included in the code as a comment for each created a class, attribute or method specified in the current model. Association class with the language C++ In order to use the class in a software project, you must associate it with the selected language, in our case with VC++. To do so, perform the following Menu: Tools => Visual C++ => Component Assigned Tools. Get the window shown in Fig. L94.

Figure L94. Assigning a class in C ++ project

173

Laboratory works

In the resulting window, select the class and drag it over the icon VC++. On the question of whether we want to create a VC++ component and associate it with the class, answer Yes and get into the window for selecting the project VC++, (Fig. L95). You can create a project or select from the existing premises for the new class in it. Click Add and OK.

Figure L95. Project Selection

You can create a host project called greenhouse using MFC App Wizard.ehe (wizard executable application) with type Single document (document single window). By and large, the class may be associated with any language supported by the code generator Rational Rose, and the association of program code will be created in the language that is associated with the class, and depend on the specific language some properties of a class. Therefore, a good idea to initial Association classes with a certain programming language. Tools menu Visual C++ After class association with the programming language you can use the main menu item Tools to Visual C++, as shown in Fig. L96. Model Assistant Model Assistant allows you to update and specify the classes in the model, using additional keywords for the required C++ code generation. Model Assistant is a window that allows you to create attributes and operations, and modify their properties (Fig. L97), and is much simpler and clearer than it does for C++. 174

Laboratory work #13

In this window, you see the following fields: – Preview (preview) shows the description of the class as defined in the moment; – Code Name (program name) displays the name of the program file for this class; – Generate Code (to create the source code) - the key that determines whether you want to create for the class source code in the language of VC ++. If the key is removed, the code generation is not going to happen and this class will not be shown in the list of classes to update the code in the Code Update (update the original text); – Class Type (type of class) allows you to set the type of the class, such as the «class», «struct» or «union»; – Documentation (documentation) allows you to specify arbitrary comments for class. If this field is empty, then the generation of source code text from it will be included in the program as a comment. This is extremely useful when viewing a software code created using a generator Rational Rose. At least, this feature allows you to create documentation for the program at the moment of creating a class.

Figure L96. Tools menu Visual C++ 175

Laboratory works

Rational Rose allows you to create comments at the design stage, it has not yet written a single line of code, which is quite convenient, because it is at the time of designing the class has not forgotten those goals and constraints created by the projected class or method. Significant opportunities offered by Rational Rose features an interactive installation methods of the class. Consider the properties of the operation calibrate, then activate the line for calibrate in the Model Assistant. The program activates the dialog box shown in Fig. L98. This window allows you to set and modify attributes for the operation, as well as certain overload in class surgery.

Figure L97. Model Assistant class temperature sensor

Assignment fields in the following: – Preview (preview) shows a description of the transaction in the manner it has been determined at the current moment; – Code Name (code name) shows the code name for the operation. It may be hidden if a name is not specified; – Return Type (type) allows you to select from a list of the type returned by an operation; – Linkage (connection) allows you to set the type of operation that can be Friend or Static:

176

Laboratory work #13

1. Static means that the operation can be addressed before the establishment of the object class; 2. Friend determines that this function, though not a member of the class, but has access to a protected and private components. Thus, determining the operation as a friendly, we thereby remove it from the class methods and implies that this function will be described outside of class. – Inline to specify operation in the keyword inline, ie, the operation will be created as inline substitution. In this case, the compiler to create the object code will try to substitute the text of the program code of the operators of her body. Thus, when multiple calls to inline functions can increase the size of the program, however, are excluded, the cost of transfer of control, and the called function returns. As the draft standard C++ in addition to saving time during program execution, the substitution function allows optimization of its code in the context of the surrounding call that otherwise can not be the most suitable for the substitution function, consisting of only a few lines; – Const determines the type of operation as the Const. – Access Level (access level) indicates the access to the operation and can be Public, Protected, or Private; – Operation Kind – type of operation Virtual, Abstract and Non-Virtual.

Figure L98. Properties calibrate operation

The mechanism for turning the virtual functions in those cases where it is necessary to put the base class function which must be performed differently in the 177

Laboratory works

derived classes. For example, the base class can describe the shape on the screen, without specifying its type, and derived classes have to describe the implementation of concrete triangles, ellipses, squares, etc. In this class, which contains at least one virtual function, called an abstract, in this case, there is no difference between the setting of Virtual or Abstract. And in fact, and in another case, the function will be created with the key word Virtual, which will require redefinition in derived classes, or at least create new child classes for the class that has a virtual function. If you click on a class attribute, it opens a window to edit the properties of the attributes shown in Fig.L99, where you can set the basic attributes of a class without leaving the Model Assistant. This window contains the following fields: – Preview (preview) description attribute indicates the same manner as it has been defined in the current moment; – Type (Type) allows you to select from a list of attribute type; – Initial Value (initialization) allows you to set a value for it to work in the facility, which allows you to quickly get the most desired result; – Access Level (access level) indicates the access attribute defines a section in which the attribute will be created: Public, Protected, or Private; – Static means that a static attribute (common to all objects of the class); – Derived indicates that the attribute is derived; – Documentation allows you to edit the description of the attribute. This window has a tab CAPE, which is designed for a class that inherits from the base classes MFS. Since the temperature sensor is not inherited from any of the classes, this tab is we do not need, we will look at its properties, when we create an application class-based MFC. Component Assignment Tool Activates the dialog box to the destination classes and components for the purpose of language class. This window allows you to create new components in the model component association with projects in specific programming languages and destination classes into components. In order to obtain the benefits of using this tool, it is necessary here to create components and not through the window in figure Browser or components. This creates the components will contain the necessary information to generate code in the selected language. This tool allows you to view the classes that are not yet assigned to the components, which reduces the chance of error. Component Assignment Tool can be opened either through Tools, and from the context menu for the component in the Code Update Tool. Update Code / Update Model (update code / model) This ability to create a Visual C++ on the model developed to update the model for an existing project created with MFC. And that is very nice, it is possible not only to pump the finished code in the program Rational Rose, as provided for menu items ++ Reverse Engineering, and support the exchange constant, that is, to work in that facility, which allows you to quickly get the most desired results. For example, you want to quickly fix something in the already finished, the program is running, and, as always, it had to be done «yesterday». Programmer quickly «tightens up» something in the source code adds or modifies methods and 178

Laboratory work #13

attributes and quickly delivers a running program. Then simply selects Update Model from code, and these changes immediately get to the desktop Rational Rose. Now, they can work normally and maintain.

Figure L99. Editing class attributes using the Model Assistant

It is no secret that the support – it's a nightmare programmer. Often easier to write code from scratch, than to understand the numerous «patches», made at different times and sometimes different people. Here «patch» is not fundamentally. The entire program is a model foreseeable. Let us assume that we have already created a draft greenhouse (it should have been What if everything is done correctly), and we know that after the last time the model was changed, the source code of the class temperature sensor It has been fixed, and must be updated. Select Update Model from code. And in the context menu of the class associated with the VC ++ also has this option, but he called the Update Model, which, however, is irrelevant, since the action performed by these items are the same. After selecting a window appears with a description of future action, it can pay off by selecting the Next (more), and besides, even to prevent it in the future appearance of stalking by setting a checkmark Do not show this page in the future (no more show this page). After that the window shown in Fig. L100. Here you can update all the model classes and separate classes, with the help of the installation and removal of the marks with certain classes. 179

Laboratory works

If the model classes have not yet been associated with any project VC++ using the button Add Component (add component) you can do it directly from this window. Some classes of the project may be an error or a lack of data when creating them in Rational Rose with subsequent code generation or when transferring data from the finished model code Rational Rose. Such classes are marked with a question mark in a circle of bright yellow. If you select a question mark, the message Rational Rose, which indicates a problem or an error in the class, and suggests methods of its elimination.

Figure L100. Window Update Model Tool

Figure L101. Synchronization code and model 180

Laboratory work #13

Then, Rational Rose received information from a Visual C++, this is loaded Microsoft Visual Studio and the Visual desired activated C++. After the exchange occurred, it may be activated by removal of the window component. If you have experimented with the received code, and then remove some of the classes, attributes or operations, the program will keep track of what elements exist in the model of Rational Rose, but not reflected in the source code. The program believes that these components have been removed from the source code and offers to remove them from the model (Fig.L101). Heed this issue. Perhaps the draft Visual C++ classes have been added, for example, using Class Wizard, and they are not reflected in the model Rational Rose. In this case, you must upgrade the code by using the Update Code (code update). We have just such a case, you can not delete anything if you do not set the flags on the proposed components. After the completion of the exchange program will be a report on how the update went. The window has two tabs: Summary – abrief overview and Log – afull report on the updated classes (Fig. L102). If all goes well, the errors and warnings should not be, as shown in the figure. A fatal error will occur if the package is installed on the computer Visual Studio 5, but not used, are working with Rational Rose 98i-2000.

Figure L102. Report conducted by the updated components

This will result in an error of renovation, and the process will fail. The process of updating the code on the changes in the model is similar. And Rational Rose allows you to select specific classes you want to update. Class Wizard (Class Wizard) Class Wizard helps you create new classes. Like most artists, he is by a serialactivated window guides the user to create a class with the necessary information. The wizard provides the ability to set three different options for creating a class: 181

Laboratory works

1. Create a new empty class. 2. Create a subclass of an already created class. 3. Create a new class for an existing template Undo Last Code Update (cancellation of last update) Paragraph Undo Last Code Update allows you to activate the dialog box, where you can replace the resulting source code in a previous version (Fig.L103). CATFISH Activates setting menu COM objects. We will not see this menu, due to the fact that in our system no such objects. Quick Import MFC 6.0 It allows you to import a class library MFC classes in the current model, so that they could use when creating the application hierarchy. Properties It allows you to set the properties of the generator Visual C++, which affect the generated code. We will not dwell on them because of the fact that our problem is rather the default settings.

Figure L103. Dialogue cancel the last update

Creating a class code As you can see, Visual Studio 6.0 with Rational Rose, Rational Rose is a perfect complement to Visual Studio. Thus, to create a class code is sufficient to use a means of Model Assistant to install the necessary properties of the generation and to update the code with the command Update Code. Technique means of Model Assistant differ somewhat from the set properties when you create a C++ code, so we will not consider them in the abstract, but by creating a code hydroponic station. 182

Laboratory work #14

The process of creating a code – aniterative process in which to produce a working application we need to make changes in both the model and the resulting source code.

Laboratory work # 14 Create a template application Agreement on the use of names Microsoft has developed for programmers a special agreement on the use of names in the programs. Under the agreement, the names are used for functions, built from verbs and nouns, and the first letters of the words – capital. For variable names, Microsoft offers a more complex system called the marking of data types. It uses a small prefix of lowercase letters, and the first name starts with a capital letter. The following is a table of prefixes offered by Microsoft. Table Prefix variables Prefix b c s dw f fn h l i lp n p pt w sz lpsz rgb

Data Types Boolean (bytes) Symbol (byte) String (char or String) Unsigned long (DWORD) 16-bit flag (bitmap) Function descriptor (handle) long integer (long) int data type Long pointer (long pointer) Integer (16 bit) Pointer (pointer) Point (two 32-bit integers) Unsigned (WORD, 16-bit) A pointer to a string that ends with 0 (string zero) Long pointer to sz (long pointer string zero) long integer containing the RGB color combination

For programs written using the library MEC, you can add that the class name begins with C, and the name of the class attribute starts with m_. And when you create classes by using VC++ automatically generated header files and class body without the letter C at the beginning of the name. Using naming conventions in the program is optional, but using software agreements do not just become easy to read, but also greatly facilitates its further support. Of course, indicate or not to indicate the variable type in its name – itis a private matter, but a habit to use such an agreement is a good practice. 183

Laboratory works

Application Structure Since we are creating a hydroponic system in the language of VC++ using library MFS, then, in order to continue to navigate the generated code of the program, a brief look at the structure of the application MFC. Application Wizard VC++ (ArrWizard) can create several types of applications, each of which is used for their own purposes. We list these types: – Single document (application runs with a single document); – Multiple document (application works with several documents); – Dialog based (application based on dialog box). In our case the most useful application structure, working with one document. The concept of «document» for the hothouse The concept of «document» in the widespread practice of programming with the filing of Microsoft. The document is now called any set of data, not just text. So, sound recording or video fragment is placed into the computer, is a document. To create a program to display and edit documents, Microsoft has created a template to work with documents, which already provides the necessary basic functions such as the display in the window saving or printing. Data on the greenhouse can also be present in the form of a document, although it is not mandatory. It's just a faster way to create a working application, than the way of creating an application from scratch based on the dialog box. In fact, if we take as a basis the document template, it is possible in a short time to create a graphic process control system in the greenhouse, which will display the status of devices in a graphical manner and subject to the operator, who can click to change the status of devices or choose another program growing. This creates an automated process control system (PCS). Classes created by the master application When you create an application template wizard application code will create the following classes. – the main application class CGreenhouseApp; – Document Class CGreenhouseDoc; – Class view CGreenhouseView; – Class for the window «About the program» CAboutDlg; – Class of the main program window SMainFrame; All applications MC++, MS are objects. Thus, the application - this is the main class that includes all the necessary documents for classes, view windows. This place is global and is created when an application is invoked. Usually Master calls it the App. By following the naming convention, the wizard will create the main application class named project, which will add at the beginning of the letter C – class (class), and at the end of the App – arr1isation (annex). And get CGreenhouseApp, which is inherited from the library class SWinArr. Master immediately override feature class CWinApp::InitInstance (), which runs the code in the first place when downloading an application initializes all the necessary resources for the application. Application Wizard creates a document class (in our case CGreenhouseDoc), which should take place processing, and inherits it from the library class CDocument, and Class Review (SGreenhouseView), which displays the data on a computer screen. The data is displayed in the window (class CMainFrame), which is inherited from the library class CFrameWnd. The above hierarchy is shown in Fig. L104. 184

Laboratory work #14

Operation OnNewDocument An important operation in the newly created class will CGreenhouseDoc operation OnNewDocument. Master, it is not created, but we will need it later to override. In this operation, all the variables are initialized, that relate to the document. Since we will display the status of devices by means of class CEditView, the most convenient would be to enable the processing of a timer event is in this class. When you create a timer handler using the tool Nodel Assistant, it will be named OnTimer.

Figure L104. Class hierarchy application

Thus, based on standard class of documents provided by MFS, we get an application in which we need to 6udet only add functionality, and for displaying the document on the screen will respond library. Now that you understand the structure of the application, you need to create the code. I advise you to create a new project VC++ to go the way of creating the project again and exclude the effects that might remain from previous experiments. Create a template application In order to associate the project with the project Rational Rose Visual C++, you need to select the window Menu => Tools => Visual C++ => Component Assignment Tool. It mouse drag the necessary classes in a row VC ++, the question of whether you want to create a component VC++ to assign the selected classes in a new component, you must answer «Yes». All classes, which is necessary to create the source code must be placed in the program components. For ease of operation will only have one component that concluded the project greenhouse. In the the Select and VC+ Project File click Add, then fill in the window for creating a new project, as indicated in Fig. L105. Thus, we will use the wizard MFC application. Create a single-window application processing document using the wizard, which will set the button Single document, as shown in 106. The following steps will show there is no need, as they can leave all the proposed options unchanged. Go through all the steps of the wizard by repeatedly click Next.

185

Laboratory works

Figure L105. Create a new C ++ project

Figure L106. Creating an application for document processing

However, in the sixth step, before you click the Finish button, change the Base class (base class) on the CEditView, as shown in Fig.L107.

186

Laboratory work #14

Figure L107. Installation of the base class for the application template

After all the processes of the program will return to the selection window of the project (Fig. L108), where you must select the newly created project.

Figure L108. Project selection window after creating a greenhouse project

187

Laboratory works

Assignment of classes in the project Click OK, and the Visual C++ ready. Now you can assign a class to the project, whose name appears below the word VC++, in the Component Assignment tool. To do this, drag and drop the necessary classes in the project. In order to get the first version of the running application, is included in the draft only classes of devices. Gradually we will expand the project, but is for quick debugging will only work with classes of devices. Import library MFS In order to be able to continue to work with classes of MFS, you must import this class library into the model. Select Menu => Tools => Visual C++ => Quick Import MFC 6.0. After this message appears on the startup classes in the model. Download the generated classes to the model Now, in the Rational Rose model can load classes by Visual C++. This class, which we have already mentioned: – the main application class CGreenhouseApp; – Document Class CGreenhouseDoc; – Class view CGreenhouseView; – Class for the window «About the program» CAboutDlg; – Class of the main program window SMainFrame; In order that they appear in the project, you must update the project to the finished code with the following sequence: Menu => Tools => Visual C++ => Update Model From Code. Now this is not necessary, because the code is necessary to make some changes to the normal compilation, however, to see how classes are displayed in the project Rational Rose, you can update the model from the code. After updating Rational Rose will automatically create a chart that reflects the structure of a class that inherits from the class library MFC. The key is to not remove classes that Rational Rose can not find in the resulting code. They are not there yet, and in order that they appear necessary update the code on the model: Menu => Tools => Visual C++ => Update Code. After the update has passed, we will get the same classes in Rational Rose model and VC++ project. The first launch of the application Start Visual Studio (if the development environment is not already running) and go to the project greenhouse. Press F7 to create an EXE file. The obtained using Rational Rose code is necessary to make small changes to create an executable file. Changes made once, stored, and when updating the model there is no need to make them again. Take a look at the protocol. The most common mistake is to «fatal error C1010: unexpected end of file while looking for precompiled header directive». This means that you must include the file «stdafx.h» in all files where there was such a mistake. Open the file and add the line #include «stdafx.h» to other operators #include. After completing this work again start generation. 188

Laboratory work #14

Unfortunately, the code generator Visual C++ Rational Rose does not support keyword typedef, and enum, so it is necessary to determine the type directly in the source code, for example, to create an include file type definition. Create the project directly to the VC++ files defs.h: Project => Add to project => New (Fig.L109).

Figure L109. Add a new header file in the project VS ++

The editor opens a window for entering into which we introduce the following definition types. #pragma once // for files include a time // status of the device on or off eEnum DeviceState {Off, On}; // Type of temperature is better to make a simple type, not class typedef float Temperature; // time of day or night enum Lights {day, night}; // to describe the type of pH typedef float pH; // types to describe the current time, hour and minute typedef unsigned int Day; typedef unsigned int Hour; typedef unsigned int Minute; Of course, you can do without overrides. After all, the word compiler typedef represents only a synonym for standard types. But to write programs to determine the types specific subject area convenient for the further support of the program and even to develop convenient to deal not with impersonal float, but with a specific Temperature. After a definitions file is created, it can be included in modules that use these definitions. Since we have created a certain temperature, then the class Temperature us is no longer needed and can be removed from the model. 189

Laboratory works

Now in some classes there are operations that return values. As long as they are created only for templates, so long as no text in such operations put any value of the appropriate type. Upon completion of these preliminary operations once again start the compilation. Now she has to go without error. Run the file (CTRL + F5). What have we got when you first start the program? We got a Windows application which has not yet perform the functions we need. However, this is a complete application includes templates we have developed classes that have only brought to operational status.

Laboratory work # 15 Adding functionality to the view class Create a menu item Work (work) Application Wizard has created for us a full-fledged word processor on the basis of which further work will be carried out. Features editor we do not need, they can be used for simpler text output on the screen. But, most importantly, the project already has a blank classes for our greenhouses. They only need to give substance. Item created in order to give the command to start the program to handle growing plan, that is when you start the program, it is waiting for the operator to command when you need to start tracking the state of the environment. This tactic is quite logical. After all, if we have created a program for the real greenhouses, it would leave the possibility of creating and editing a variety of plans for growing plants and device configuration greenhouses, such as indications of their location and quantity. Only after that could start growing plan. This menu has been created as follows: add a new item to the resource Menu button and assigned it ID = ID_WORK_STARTPLAN, as shown in Fig. L110.

Figure L110. Adding a menu item in the resource IDR_MAINFRAME

Association of the operation to the menu item In order for this item began to work, it must be associated with the operation of the class for which there are two ways: 1. Create operation using Visual Studio Class Wizard (Fig.L111). 2. Create the processing of the item in Rational Rose.

190

Laboratory work #15

Figure L111. Create a menu handler in ClassWizard

The second option is the most interesting for us. To use it, go to the Rational Rose Update Model and draw from the code (the Menu => Tools => Visual C++ => Update Model From Code). Now you can create it in a class of processing CGreenhouseView. To do this, select the class, for example, in the Browse window or LogicalView and call for him to Model Assistant from the context menu. It just manifested the depth of integration capabilities Rational Rose and VC++. After switching to the tab MFS we get access to all of the attributes and operations of this class and all parent classes, for which there is no need to study the class hierarchy MFS. To create a handler. for the team ID_WORK_STARTPLAN, highlight Command Handlers (command handler), and from the context menu, select New Command Handler (new handler). Then activate the window shown in Fig. L112. Now in line Command Handler formed OnWorkStartplan new paragraph, which includes information about a new handler (Fig. L113). In the same way here, you can add any new handlers for the menu, and you can create them here first, and then add to the resources menu or other resources. Now you can add other operations that we need to work on.

Figure L112. Creating a menu command handler in Rational Rose 191

Laboratory works

Figure L113. Information handler teams in the Model Assistant

Adding an operation to Model Assistant To display the current status and performance of sensors is necessary to create an operation that would have deduced this information in the main window. We call it the Message. To add an operation, it is necessary to row Operations (operations) from the context menu select New Operation (new operation) and fill the parameters of the operation as shown in Fig. L114. Do not forget that when filling out the names and types of variables, you must first specify a name, and then after a colon, - the type. In any case, you can always rename a variable, if there was something wrong filled in using RClick => Rename.

Figure L114. Entering operation Message

Message Tracking timer We also need a timer to track messages. Earlier, before it finally became known to the structure of the application, we planned to build a timer directly to the classroom EnvironmentalController, but not brushed aside the possibility of determining the 192

Laboratory work #15

timer in some outside class. Now you can determine exactly where to place the class. We include initialization and processing of the timer class CGrennhouseView. To create the timer handler MFC tab select Windows Message (posts Windows) and put the point OnTimer (Fig. L115).

Figure L115. Enable the timer handler

For normal operation, the timer must be added to the class attribute m_TimerID with type UINT. This variable will store the timer identifier. If the identifier is zero, the timer is not activated, and if not zero, the timer is running. This information we use when we fill handler OnWorkStartplan. In the event that the application is complete before stopping the timer to release the resource Windows (because the number of resource limited), you must stop when you close the timer. To do this, check the box operation by Destroy Window Model Assistant => MFC => CWnd => Destroy Windows = ON. And, of course, to initialize the timer, set the mark to generate a class constructor. Editing class template CGrennhouseView. Thus, the template for creating a class CGrennhouseView fully created. Next you need to add the content to work directly. This can be done after you upgrade the code on the model. Since this process is not instantaneous, it is possible to update only the class code CGrennhouseView. After updating the code, you can fill in the resulting pattern follows. In the constructor, a variable timer zero out. CGrennhouseView :: CGrennhouseView () { m_TimerID = 0; } Message fill in the following manner. void CGrennhouseView:Message(LPCTSTR lpszMessage) { 193

Laboratory works

CString strTemp=lpszMessage; strTemp+=_T(“\r\n”); int len=GetWindowTextLength(); GetEditCtrl().SetSel(len,len); GetEditCtrl().ReplaceSel(strTemp); } This operation will only be displayed in the main window reworked its line, adding newline characters. Including the initialization of the timer operation OnWorkStartplan. Note that you can stop the execution of the plan, re-select the same menu item. In this case, the timer is set to update once per second (the second parameter of the library function SetTimer allows you to set the interval in milliseconds). void CGrennhouseView:: OnWorkStartplan () { if (m_TimerID!=0){ KillTimer(m_TimerID); m_TimeID=0; Message(“Stop Plan”); } else { m_TimerID=SetTimer(1,1000,NULL); Message(“Start Plan”); } } At the same time examine how the operation Message. Change the operation DestroyWindow: BOOL CGrennhouseView::DestroyWindow () { if (m_TimerID!=0){ KillTimer(m_TimerID); m_TimeID=0; } return CEditView:: DestroyWindow (); }

Figure L116. Screen application after start and stop work plan

194

Laboratory work #15

И, собственно, для обработчика таймера включим сообщение о его работе void CGrennhouseView::OnTimer(UINT nlDEvent) { Message (“Timer”); CEditView:: OnTimer(nlDEvent); } Make these changes and create an executable file. If there are errors, correct them and run the program. Select Work, while in the program window will display messages saying that the timer is running. Stop the timer by selecting another item Work, then the program screen should look like Fig.L116.

195

Laboratory works

Keys to the tests № question Chapter 1 Chapter 2 Chapter 3 Chapter 4 Chapter 5 Chapter 6 Chapter 7 Chapter 8 Chapter 9 Chapter 10

196

1

2

3

4

5

6

7

8

9

10

b c a b d b a b b b

b b d a a a d a a b

b d b b c a a,c b,c,d a,d b

c a b b a b a a b a

a a d a b b a c c b

b a a a a a b b b a

b c a c b d b b a a

b b e b b a b a b b

c a c a c d c a a,b b

b b b b b b d a b b

Laboratory work #15

References 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21.

Леффингуэлл Д., Уидриг Д. Принципы работы с требованиями к программному обеспечению. Унифицированный подход. – М.: Вильямс, 2002. – 448 с. Грекул В.И., Денищенко Г.Н., Коровкина Н.Л. Проектирование информационных систем Интернет-университет информационных технологий. − ИНТУИТ.ру, 2008. Мartіn Fоwlеr. UМL Dіstіllеd: AB rіеf Guіdеtо thе Standard Оbjеct Моdеlіng Languagе (3rd Еdіtіоn). − Addіsоn-WеslеуPrоfеssіоnal, 2003. Alan Dеnnіs, Barbara Halеу Wіхоm, Davіd Tеgardеn. Sуstеms Analуsіs and Dеsіgn wіth UМL Vеrsіоn 2.0: An Оbjеct-Оrіеntеd Apprоach. − Jоhn Wіlеу & Sоns, Іnc., 2005. Gradу Bооch, Jamеs Rumbaugh, Іvar Jacоbsоn. Thе Unіfіеd Моdеlіng Languagе Usеr Guіdе. Addіsоn Wеslеу. – 1998. Буч Г. Объектно-ориентированное проектирование с примерами применения. – М.: Конкорд, 1992. Грехем И. Объектно-ориентированные методы. Принципы и практика. – М.: Вильямс, 2004. – 880 с. Константайн Л., Локвуд Л. Разработка программного обеспечения. – СПб.: Питер, 2004. Арлоу Дж., Нейштадт А. UML 2 и унифицированный процесс. Практический объектноориентированный анализ и проектирование. – СПб.: Питер, 2007. – 617 с. Рамбо Дж. Объектно-ориентированное моделирование и разработка. – М.: Радио и связь, 2007. – 544 с. Буч Г. Объектно-ориентированный анализ и проектирование с примерами приложения на С++. – М.: Издательство «Бином», 1999. Трофимов С.А. Case-технологии. Практическая работа в Rational Rose. – М.: БиномПресс, 2002. – 288 с. Вендров А.М. Проектирование программного обеспечения экономических информационных систем. – М.: Финансы и статистика, 2002. – 352 с. Якобсон А., Буч. Г. Рамбо Дж. Унифицированный процесс разработки программного обеспечения. – СПб: Питер, 2002. – 496 с. Липаев В.В. Системное проектирование сложных программных средств для информационных систем. – М.: ЛОРИ, 1999. Одинцов И. Профессиональное программирование. Системный подход. − СПб.: БХВПетербург, 2002. Торстейнсон П. Оберг Р. Архитектура. NET и программирование на Visual С++. – М.: Издательский дом «Вильямс», 2002. Буч Г., Рамбо Дж., Джекобсон А. Язык UML. Руководство пользователя. – М.: ДМК, 2000. Гома Х. UML. Проектирование систем реального времени, распределенных и параллельных приложений. – М.: ДМК, 2002. Лешек. А. Анализ требований и проектирование систем. Разработка информационных систем с использованием UML. – М.: Вильямс, 2002 – 432 с. Федотова Д.Э., Семенов Ю.Д., Чижик К.Н. CASE-технологии: практикум. – М.: Горячая линия, 2005. – 160 с.

197

Laboratory works

Educational issue Jomartova Sholpan Abdrazakovna Zhumanov Zhandos Maratovich FUNDAMENTALS OF UML Educational manual Computer page makeup N. Bazarbaeva Cover designer: K. Umirbekova

IS No.10403 Signed for publishing 02.02.16. Format 70x100 1/12. Offset paper. Digital printing. Volume 16,4 printer’s sheet. Edition 80. Order No.237 Publishing house «Qazaq university» Al-Farabi Kazakh National University, 71 Al-Farabi, 050040, Almaty Printed in the printing office of the «Qazaq university» publishing house