15.2. Purpose and composition of the component diagram
The component diagram allows you to determine the composition of software components, which can be source, binary and executable code, as well as to establish dependencies between them.
When developing component diagrams, the following goals are pursued:
Specification of the general structure of the source code of the system;
Specification of the executable version of the system.
This diagram provides a consistent transition from logical to physical representation of the system in the form of software components. Some components can only exist at compile time program code, others - at the stage of its execution. The main elements of a diagram are components, interfaces and dependencies between them. In addition, it can display the key classes included in the components.
Component (English component) is the physical part of the system. Components, which are files with source code of classes, libraries, executable modules, etc., which must have a consistent set of interfaces. The following graphic symbols are used to represent them graphically.
Rice. 15.2. Component examples
Inside the rectangle is written the name of the component and possibly some additional information in the form of a tagged value.
Components can have the following standard stereotypes:
- "file" - any file, except for the table:
o "executable" - program (executable file);
o "library" - static or dynamic library;
o "source" - a file with the source code of the program;
o "document" - other files (for example, help file);
- "table" - database table.
Inside a component, just like a class, additional sections can be allocated, in which the provided or required interfaces and classes, methods (operations), the name of the component file (artifacts), etc. are specified.
Rice. 15.3. Component with sections
Interface (English interface) is an externally visible, named set of operations that a class, component or subsystem can provide to another class, component or subsystem to perform its functions. In some programming languages, in particular in Java, an interface is a separate class that is included and implemented (instantiated) as part of the program code of operations as part of other classes. On the component diagram, the interface is displayed in the same way as on (to the left of the component, the interfaces required for operation, to the right - provided).
Rice. 15.4. Interface display methods
Association relation displayed between components and their interfaces. Addiction relationship means the dependence of the implementation of some components on the implementation of others. This is possible in the following cases:
In the methods of the classes of one component (dependent), methods are called or the attributes of the classes of another component (independent) are called;
A component consists of other components (for example, when building an executable file from files with source codes);
A component reads or writes data to another component;
Relationship between database tables;
Due to the multipurpose purpose of a component diagram, the following rules and guidelines should be followed during its development.
1. Before developing component diagrams, it is necessary to decide what physical parts (files) the software system will consist of. In this case, two tasks must be solved - the distribution of classes in source code files and in subsystems. In the latter case, the distribution of classes into specialized (functionally oriented to the subject area) packages can help. At this stage, attention should be paid to such an implementation of the system that would provide the possibility of reusing the code due to rational decomposition of the system, i.e., minimize the number of connections between components.
2. When specifying the general structure of the source code of the system, it is necessary to take into account the specifics of the programming language with which the components are implemented. In particular, in Java, it is recommended to describe a separate class in a separate file, despite the fact that the language allows you to describe several classes in one file and use the mechanism of internal classes. The component diagram used for this purpose is shown in the following figure.
Rice. 15.5. Fragment of a component diagram specifying the structure of the source code
The diagram in Fig. 15.5 shows the composition of the classes (files) that make up the executable component iskraPUT.jar, as well as the dependencies between the classes.
3. For the specification of an executable version of the system, it is necessary to have a preliminary topology of the system, that is, a sketch. For each node in the network, a component diagram can be built, defining the set of files required for the operation of the subsystem (s) at a separate workstation.
Rice. 15.6. Example of a component diagram specifying the composition of components at a user's workplace
4. A diagram can represent the dependency relationships between components and the classes they contain. This information is essential to ensure consistency between the logical and physical representations of the system. In this case, dependence can be shown in two ways:
Show classes separately from the component and associate the component with each class in a dependency relationship. For example, in Fig. 15.5 instead of components with the "java" extension, show the corresponding classes;
Display the classes inside the component symbol.
6. To visually display the specifics of components, you can use graphic stereotypes instead of a standard component symbol with a string stereotype.
The UML is now the standard notation for visual modeling of software systems, adopted by the Object Managing Group (OMG) in the fall of 1997, and is supported by many object-oriented CASE products.
The UML standard offers the following set of diagrams for modeling:
· Use case diagram - for modeling the business processes of an organization or enterprise and determining the requirements for the information system being created;
· Class diagram (class diagram) - for modeling the static structure of the classes of the system and the connections between them;
Behavior diagrams
· Interaction diagrams;
· Sequence diagrams - to simulate the process of exchanging messages between objects within a single use case;
· Collaboration diagram - for modeling the process of messaging between objects within one use case;
· Statechart diagram - for modeling the behavior of system objects during the transition from one state to another;
· Activity diagram - for modeling the behavior of the system in the framework of various use cases, or modeling activities;
Implementation diagrams:
Component diagrams - to model the hierarchy of components (subsystems) of an information system;
· Deployment diagram - to model the physical architecture of the designed information system.
In fig. 1.1 presents an integrated model of the information system, including the basic diagrams that should be developed in this course project.
Rice. 1. An integrated model of an information system in the notation of the UML language
4.2. Use case diagram
A use case is a sequence of actions performed by the system in response to an event triggered by some external object (actor). A use case describes a typical interaction between a user and a system. In the simplest case, the use case is determined by discussing with the user the functions that he would like to implement in a given information system. In the UML, a use case is depicted as follows:
Fig. 2. Use case
Actor is the role that the user plays in relation to the system. Actors represent roles, not specific people or job titles. Although they are depicted as stylized human figures in use-case diagrams, the actor can also be an external information system that needs some information from the system. Show actors in your diagram only when they really need some use cases. In the UML, actors are represented as shapes:
Fig. 3. Actor (actor)
There are three main types of actors:
· Users;
· Systems;
· Other systems interacting with this;
Time becomes an actor if the launch of any events in the system depends on it.
4.2.1. Relationships Between Use Cases and Actors
In UML, use-case diagrams support several types of relationships between diagram elements:
Communication,
Inclusion (include),
Extension (extend),
Generalization.
Communication link Is the relationship between the use case and the actor. In the UML, communication links are shown using a one-way association (solid line).
Fig. 4. Communication link example
Inclusion link applies in situations where there is a piece of system behavior that is repeated in more than one use case. These links are usually used to model a reusable function.
Extension link is used to describe changes in the normal behavior of a system. It allows one use case to use functionality another use case.
Fig. 5. Example of connection of inclusion and extension
Generalization link indicates that multiple actors or classes have general properties.
Fig. 6. Generalization link example
4.3.
Interaction diagrams describe the behavior of interacting groups of objects. Typically, an interaction diagram covers the behavior of objects within only one use case. Such a diagram displays a number of objects and the messages that they exchange with each other.
Message Is the means by which the sender object requests the recipient object to perform one of its operations.
Informative message Is a message that supplies the recipient object with some information to update its state.
Request message (interrogative) Is a message requesting the issuance of some information about the recipient object.
Imperative message Is a message that asks the recipient to take some action.
There are two types of interaction diagrams: sequence diagrams and collaboration diagrams.
4.3.1. Sequence diagrams
Sequence diagram reflects the flow of events that occur within a single use case.
All of the actors (actors, classes, or objects) involved in a given scenario (use case) are shown at the top of the diagram. Arrows correspond to messages passed between an actor and an object, or between objects to perform required functions.
In a sequence diagram, an object is drawn as a rectangle with a vertical dashed line drawn downward. This line is called the lifeline of an object ... It is a fragment life cycle object in the process of interaction.
Each message is represented as an arrow between the life lines of two objects. Messages appear in the order shown on the page from top to bottom. Each message is tagged with at least the message name. Optionally, you can add arguments and some control information as well. You can show self-delegation - a message that an object sends to itself, with the message arrow pointing to the same lifeline.
Rice. 7. Example of a sequence diagram
4.3.2. Collaboration diagram
Cooperation diagrams display the flow of events within a specific scenario (use case). Messages are ordered by time, although collaboration diagrams focus more on relationships between objects. A collaboration diagram represents all the information that a sequence diagram contains, but a collaboration diagram describes the flow of events differently. It makes it easier to understand the connections that exist between objects.
In a collaboration diagram, as in a sequence diagram, arrows indicate messages exchanged for a given use case. Their temporal sequence is indicated by the numbering of messages.
Rice. 8. Example of a cooperation diagram
4.4. Class diagram
4.4.1. General information
Class diagram defines the types of classes of the system and various kinds of static links that exist between them. Class diagrams also depict class attributes, class operations, and constraints that apply to relationships between classes.
A UML class diagram is a graph, the nodes of which are elements of the static structure of the project (classes, interfaces), and the arcs are the relationships between nodes (associations, inheritance, dependencies).
The class diagram depicts the following elements:
· Package - a set of model elements that are logically related to each other;
· Class - a description of the general properties of a group of similar objects;
· Interface is an abstract class that defines a set of operations that an object of an arbitrary class associated with this interface provides to other objects.
4.4.2. Class
Class is a group of entities (objects) that have similar properties, namely, data and behavior. An individual representative of a class is called a class object, or simply an object.
The behavior of an object in UML is understood as any rules for the interaction of an object with the outside world and with the data of the object itself.
In the diagrams, the class is depicted as a rectangle with a solid border, divided by horizontal lines into 3 sections:
The top section (name section) contains the class name and other general properties (in particular, the stereotype).
The middle section contains a list of attributes
At the bottom is a list of class operations that reflect its behavior (actions performed by the class).
Any of the sections of attributes and operations may not be displayed (as well as both at once). No need to draw for missing section dividing line and somehow indicate the presence or absence of elements in it.
Additional sections, such as Exceptions, may be introduced at the discretion of a particular implementation.
Rice. 9. Example class diagram
4.4.2.1.Class stereotypes
Class stereotypes are a mechanism for categorizing classes.
There are three main class stereotypes defined in the UML:
Boundary
Entity
Control.
4.4.2.2.Boundary Classes
Boundary classes are classes that are located at the border of the system and the entire environment. These are displays, reports, interfaces with hardware (such as printers or scanners), and interfaces with other systems.
To find the boundary classes, you need to examine the use case diagrams. For every interaction between an actor and a use case, there must be at least one boundary class. It is this class that allows the actor to interact with the system.
4.4.2.3.Entity classes
Entity classes contain stored information. They have greatest value for the user, and therefore they often use terms from the subject area in their names. Typically, for each entity class, a table is created in the database.
4.4.2.4.Control Classes
Control classes are responsible for coordinating the actions of other classes. Typically, each use case has one control class that controls the sequence of events for that use case. The controlling class is responsible for coordination, but it does not carry any functionality itself, since the other classes do not send it a lot of messages. Instead, he sends many messages himself. The manager class simply delegates responsibility to other classes, for this reason it is often referred to as the manager class.
There may be other control classes in the system that are common to multiple use cases. For example, there might be a SecurityManager class that is responsible for monitoring security events. The TransactionManager class is responsible for coordinating messages related to database transactions. There may be other managers to deal with other elements of the system's operation, such as resource sharing, distributed data processing, or error handling.
In addition to the stereotypes mentioned above, you can create your own.
4.4.2.5.Attributes
An attribute is a piece of information associated with a class. Attributes store encapsulated class data.
Since the attributes are contained within the class, they are hidden from other classes. Therefore, you may need to specify which classes are allowed to read and modify attributes. This property is called attribute visibility.
An attribute can have four possible values for this parameter:
Public (general, open). This visibility value assumes that the attribute will be visible to all other classes. Any class can view or change the value of the attribute. In UML notation, the common attribute is preceded by a "+" sign.
Private (closed, secret). The corresponding attribute is not visible to any other class. A private attribute is denoted with a "-" according to UML notation.
Protected Such an attribute is available only to the class itself and its descendants. The UML notation for a protected attribute is the "#" sign.
Package or Implementation Assumes that this attribute is generic, but only within its package. This type of visibility is not indicated by any special icon.
With the help of closedness or security, it is possible to avoid a situation when the value of an attribute is changed by all classes of the system. Instead, the logic for modifying an attribute will be wrapped in the same class as the attribute itself. The visibility parameters you set will affect the generated code.
4.4.2.6.Operations
Operations implement class-specific behavior. An operation has three parts - name, parameters and return type.
Parameters are the arguments received by the "input" operation. The return type refers to the result of the action of the operation.
In a class diagram, you can display both the names of the operations and the names of the operations along with their parameters and return type. To reduce the workload of the diagram, it is useful to show only the names of operations on some of them, and on others their full signature.
In the UML, operations have the following notation:
Operation Name (Argument: Data Type of Argument, Argument2: Data Type of Argument2, ...): Return Type
There are four different types operations:
Implementation operations;
Control operations;
Access operations;
Auxiliary operations.
Implementation operations
Implementor operations implement some business functions. Such operations can be found by examining interaction diagrams. Diagrams of this type focus on business functions, and each message in the diagram can most likely be associated with an implementation operation.
Each implementation step must be easily traceable to the corresponding requirement. This is achieved at various stages of the simulation. An activity is derived from a message in an interaction diagram, messages are derived from a detailed description of an event flow that is generated based on a use case, and the latter is derived from requirements. The ability to trace this entire chain ensures that every requirement is implemented in code, and every piece of code implements a requirement.
Control operations
Manager operations control the creation and destruction of objects. Class constructors and destructors fall into this category.
Access operations
Attributes are usually private or protected. However, other classes sometimes need to view or change their values. There are access operations for this. This approach makes it possible to safely encapsulate attributes within a class, protecting them from other classes, but still allows controlled access to them. It is standard practice to create Get and Set operations for each class attribute.
Auxiliary operations
Helper operations are those operations of a class that it needs to fulfill its responsibilities, but which other classes should not know anything about. These are private and protected operations of the class.
To identify transactions, follow these steps:
1. Explore sequence diagrams and cooperative diagrams. Most of the messages in these diagrams are implementation activities. Reflective messages will be auxiliary operations.
2. Consider control operations. You might need to add constructors and destructors.
3. Consider access operations. For each class attribute that other classes will need to work with, you need to create Get and Set operations.
4.4.2.7.Connections
A relationship is a semantic relationship between classes. It enables a class to learn about the attributes, operations, and relationships of another class. In other words, for one class to be able to send a message to another in a sequence diagram or a cooperative diagram, there must be a relationship between the two.
There are four types of relationships that can be established between classes: associations, dependencies, aggregations, and generalizations.
Communication association
Association is the semantic link between classes. They are drawn on the class diagram as an ordinary line.
Rice. 10. Communication association
Associations can be bidirectional, as in the example, or unidirectional. In the UML, bi-directional associations are drawn as a simple line without arrows or with arrows on either side. On a unidirectional association, only one arrow is depicted showing its direction.
The direction of the association can be determined by examining sequence diagrams and cooperative diagrams. If all messages to them are sent by only one class and are received only by another class, but not vice versa, a unidirectional relationship takes place between these classes. If at least one message is sent in the opposite direction, the association must be bidirectional.
Associations can be reflective. Reflexive association assumes that one instance of a class interacts with other instances of the same class.
Communication addiction
Dependency relationships also reflect the relationship between classes, but they are always unidirectional and show that one class depends on the definitions made in the other. For example, class A uses methods of class B. Then when class B changes, you need to make the corresponding changes in class A.
Dependency is depicted by a dashed line drawn between two chart elements, and the element anchored to the end of an arrow is considered to be dependent on the element anchored to the beginning of that arrow.
Rice. 11. Communication addiction
When generating code for these classes, no new attributes will be added to them. However, the language-specific statements required to support the communication will be generated.
Link aggregation
Aggregations are a tighter form of association. Aggregation is a connection between a whole and a part of it. For example, you might have a class for Car, as well as classes for Engine, Tires, and classes for other parts of the car. As a result, an object of the Car class will consist of an object of the Engine class, four objects of Tires, etc. Aggregations are visualized as a line with a diamond for a class that is a whole:
Rice. 11. Communication aggregation
In addition to simple aggregation, the UML introduces a stronger form of aggregation called composition. According to the composition, an object-part can only belong to a single whole, and, in addition, as a rule, the life cycle of parts coincides with the cycle of the whole: they live and die with it. Any removal of the whole extends to its parts.
This cascading deletion is often seen as part of the definition of aggregation, but it is always implied when the multiplicity of roles is 1..1; for example, if it is necessary to delete a Customer, then this deletion must apply to Orders (and, in turn, to Order Lines).
Component Diagram - A physical layer diagram that serves to
views of software components and dependencies
between them.
Component diagram is designed for the following
goals:
Visualization of the general structure of the source code
software system.
Specification of the executable version of the software
systems.
Ensuring reusability of individual
fragments of program code.
Representation of conceptual and physical base layouts
data.
Component
- a model element representing some modularpart of a system with encapsulated content,
whose specification is interchangeable in its
surroundings.
The name of the component instance is written in the same way as the name
life lines on interaction diagrams as follows
format (BNF):
<имя-экземпляра-компонента>::=[<собственное-имякомпонента>] [‘:’<имя-типа>],
in this case, the proper name of the component is written with
a lowercase letter, and as the name of the component instance
at least one term must be present.
Examples of images of a simple component and a component with interfaces
IDialog"Component"
Order
ISe ns or
IApplication
"Component"
Control p
Examples of component images in black and white box notation
"Component"Order
"Provided interf aces"
The location of your macaw
Escort
"Required interf aces"
Ordered
Customer
"Component"
Order
"Provided interf aces"
The location of your macaw
Escort
"Required interf aces"
Ordered
Customer
"Realizations"
Title okOrder
St rokaTov macaw
"Artifacts"
Order.jar
Interfaces
Provided interface -the interface that the component offers for its
surroundings.
Required interface - the interface
which the component needs from its environment for
performance of the declared functionality, contract or
behavior.
Ordering
Product
"Component"
Product
Ordering
Product
Escort
Invoice
"Component"
Order
Customer
Order Title
order
element
1
*
Item String
Location
Goods
Representation of interfaces in the form of a classifier symbol with dependency and implementation relationships
"Interface"Ordering
Product
"Use"
find iPoI mei ()
set number ()
will receive Det ali ()
"Component"
Order
"Interface"
Location of the Goods
assign ()
change()
will receive Det ali ()
Ports
A port defines a distinguishable point of interaction betweencomponent and its environment or between
component and its internals
Port name is optional
If there is no port name, its type is associated with the type
the interface to which the port is associated.
Ordering
Product
"Component"
Order
Customer
Order Title
order
Accompaniment
element
1
*
Item String
Location
Goods
Assembly connector
- a connector that connects two components inthe context of the provided and required services.
Accompaniment
Accompaniment
"Component"
Order
Order my product
"Component"
:Order
Order my product
Order my product
Order my product
"Component"
Product
"Component"
:Product
10. Example of a diagram of components with collecting connectors for the same interfaces
: Canceled OrderLocation
Location
Goods
:Warehouse
Customer
Customer
Person
:Order
: Physical
Face
Location
Organization
Accompanying
:The supplier
:Company
Product
Ordering
Accompaniment
Product
:Service
:Product
11. Delegation connector
- a connector that binds the external contract of a component toimplementation of this behavior by the internals of this
component.
A delegate connector performs one of the following tasks:
Transmitting messages or signals to the port
component from the outside, for processing in some internal
part of a component or other port.
Transmission of messages or signals from some
inside the component, for processing into an external port
component.
Location
Goods
"Component"
Order
: Order Title
: Item String
Customer
12. An example of the internal structure of a component instance
LocationGoods
"Component"
:Score
"Delegate"
Location
Goods
"Component"
:Order
Customer
Customer
"Component"
: Physical
Face
Check
Ordering
Product
Ordering
Product
"Component"
:Product
"Delegate"
Check
13. Example of a dependency relationship between a component
Canceled OrderPhysical
Face
Warehouse
Order
The supplier
Company
Service
Product
14. Dependency Relationships in Component Diagram with Interfaces
LocationGoods
Person
Customer
Physical
Face
Order
Location Tracking
Ordering
Product
The supplier
Accompaniment
Service
Ordering
Product
Product
Organization
Company
15. Realization
- specialization of dependency relationship for communicationcomponents with classifiers that implement
functionality of this component
Component implementation can be further labeled
with the "implement" stereotype
"Component"
Order
<
Heading
Order
<
Line
Goods
16. Image of graphic stereotypes of G. Buch's components
Dialog.dllInde x.htm l
Conte xt .hlp
M ain.cpp
17. Graphic stereotypes of J. Conallen's components
The server page represents a web pagecontaining scripts to be executed by the server.
These scripts can interact with server side
resources such as databases, business logic and external
systems.
The operations of the implemented class components are
script functions, and their attributes are variables,
visible within this page.
<
18. Client page
<Represents a Web page in HTML format, and
data, interface elements, and even business logic.
Client pages are rendered by client browsers
and may contain scripts that are interpreted
browser.
Client page operations can match
functions contained in script descriptors
pages.
The attributes of the client page correspond to the declared
in script descriptors the variables that are available
any function within this page.