当前位置:网站首页>UML series articles (28) architecture modeling - collaboration

UML series articles (28) architecture modeling - collaboration

2022-06-11 03:27:00 CoderIsArt

  • Collaboration 、 Implementation and interaction
  • Modeling the implementation of use cases
  • Modeling the implementation of operations
  • Modeling mechanisms
  • The concretization of interaction

In the context of system architecture , Collaboration allows you to name a concept block that includes both static and dynamic aspects . Collaboration is a class 、 Names of groups of interfaces and other elements , They work together , Provides a stronger cooperative behavior than the sum of the various parts .

Collaboration can be used to specify the implementation of usage and operation , And model the important system mechanism of the architecture .

1. introduction

A software intensive system with good quality not only has reasonable functions , It should also reflect the harmony and balance of the design , To make it easy to modify . This harmony and balance often comes from the fact that : All well - structured object - oriented systems are full of patterns . Take a look at good object-oriented systems , You will find that some elements work together in a common way , Provides a stronger cooperative behavior than the sum of all its components . In a well structured system , Many elements will participate in different mechanisms in different combinations .

stay UML in , Modeling mechanisms with collaboration . Collaboration assigns a name to the interactive building blocks in the system , It contains both structural and behavioral elements . for example , There may be a distributed management information system , Its database is distributed on several nodes . From the perspective of users , Updating information looks like an atomic action ; But from the inside of the system , It's not that simple , Because this action needs to access several machines . To give a simple description , Need to design a transaction mechanism , This enables customers to use it for this or even across multiple databases , But it seems simple 、 Atomic transaction naming . Such a mechanism may span multiple classes , They work together , To complete a transaction . Many of these classes can also be included in other mechanisms , For example, mechanisms that make information permanent . A collection of these classes ( The structural part ) The interaction with them ( The behavior part ) Together they form a mechanism , stay UML Collaboration can be used to express .

Collaboration can not only name the mechanism of the system , It can also be used as the implementation of usage and operation .

   UML Provides a graphical representation for collaboration , Imaginary frame ellipse . This representation allows you to visualize the structural and behavioral building blocks of the system , Especially when these building blocks cover classes 、 Interfaces and other elements in the system .

2. Terms and concepts

    Collaboration (collaboration) It's a set of classes 、 A community of interfaces and other elements , They work together to provide more cooperative behavior than the sum of the components . Collaboration is also about a category like ( Including class 、 Interface 、 artifacts 、 Node or usage ) A specification of how elements such as or operations are implemented by a set of classes and associations that play a particular role in a particular way . Usually , The graphical representation of collaboration is to draw it as a dashed ellipse .

2.1 name

    Each collaboration must have a name that is different from other collaborations . name (name) Is a text string . A single name is called a simple name (simple name); Restricted name (qualified name) Is the collaboration name prefixed with the package within which the collaboration exists .

2.2 structure

    Collaboration has two aspects : One is the structural part , It details the classes that work together to accomplish collaboration 、 Interfaces and other elements ; The second is the behavior part , It details the dynamics of how these elements interact .

    The structural part of the collaboration is an internal ( Reunite with ) structure , It can include pairs of classes 、 Interface 、 Any combination of components and nodes . In collaboration , These categories can be used in a variety of commonly used UML Relationship ( Including connections 、 Generalization and dependencies ) To organize . in fact , The structural aspects of collaboration can use UML All structural modeling mechanisms for .

    Unlike structured classes , Collaboration cannot have its own structural elements , Instead, just reference or use classes declared elsewhere 、 Interface 、 artifacts 、 Nodes and other structural elements . This is why collaboration is called a conceptual block in the system architecture rather than a physical block . A collaboration can span multiple levels of the system . Besides , The same element can appear in multiple collaborations .

    A collaboration called message communication between nodes can be defined in the retail system , It describes in detail the details of secure message communication between nodes .

2.3 Behavior

The structural part of the collaboration is usually represented by a composite structure diagram , The behavior part is usually represented by an interaction diagram . The interaction diagram details an interaction , This interaction represents a behavior , This includes a set of messages exchanged between a set of objects in a specific context for a specific purpose . An interactive context is provided by the collaboration that includes it , This collaboration identifies the classes whose instances might participate in this interaction 、 Interface 、 artifacts 、 Nodes and other structural elements .

      The behavioral parts of collaboration can be described by one or more interaction diagrams . If you want to emphasize the chronological order of messages , Just use the sequence diagram . If you want to emphasize the structural relationship between objects during collaboration , Then the collaboration diagram . Because how often they are semantically equivalent , So both of these graphs can be used .

    Expand the messages between collaboration nodes in the above figure to display the interaction diagram shown below .

 

4. Organization and cooperation

    The core of the system architecture is found in its collaboration , Because the mechanisms that form the system represent important design decisions . All well structured object-oriented systems are composed of a group of appropriately sized and standardized collaborations , So it is very important to organize the cooperation . There are two relationships related to collaboration that are worth considering

1) There is a relationship between collaboration and what it does . Collaboration can implement both a category and an operation , This means that the collaboration represents in detail the structural and behavioral implementation of the class or operation .

2) There are also relationships between collaborations . Some collaborations can refine others , This relationship can be modeled as a refined relationship . 

3. Common modeling techniques

1) Modeling characters

The following figure shows an incomplete scenario for the initial call in the switch context .

 

 

2) Modeling the implementation of use cases

The following figure shows a set of usage extracted from the credit card verification system

3) Modeling the implementation of operations

 

4) Modeling mechanisms

      For all well structured object-oriented systems , Will find a series of patterns . One side , You can find some idioms , They represent the usage patterns of the implementation language . On the other hand , You will find some architectural patterns and frameworks that depict the entire system and form a specific style . In between , You will find mechanisms that represent common design patterns in the system , Through these mechanisms , Things in the system interact with each other in a common way . It can be used UML Model these mechanisms as collaboration .

4. Tips and techniques

    When used UML When modeling collaboration , Remember that each collaboration can represent an implementation of a use case or operation , It can also exist alone as a mechanism of the system . A well structured collaboration , The following requirements shall be met :

  • Including structure and behavior .
  • Provide an explicit abstraction of the recognizable interactions in the system .
  • Rarely are they completely independent , It's about crossing over with other collaborative structural elements .
  • Is understandable , And it's simple .

When used UML When drawing a collaboration , Follow the following strategy :

  • Only if you understand this collaboration and other collaborations 、 category 、 The relationship between the operation or the whole system is necessary , This collaboration is shown in the figure , Otherwise, only save it in the base frame of the model .
  • Organize collaboration according to the categories or operations represented by collaboration , Or organize the collaboration in the package related to the whole system .
原网站

版权声明
本文为[CoderIsArt]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206110323085374.html