Speaking of the package diagram, let's take a look at the package
1. What is a package?
A package can be directly understood as a namespace and folder, which is used to organize the encapsulation of graphics.
2. What is the role of the package?
- Logically modularize a complex Graph
- OrganizationSource code
3. When will the package be used?
From the perspective of object-oriented software development, classes are the basic construction blocks for building the entire system. However, for a large application system, there will be hundreds of classes. In addition to the associations and multiple features in the system, the complexity must be greatly exceeded. This introduces the block of grouping transactions such as "package.
4. Package name
Each package must have a name different from other packages.
5. Package symbols
6. elements in the package
A package can contain a variety of other elements, including classes, interfaces, components, nodes, collaboration, use cases, and even other packages or diagrams.
Note: If the package is unwrapped, the elements in the package are also removed.
7. Package visibility
- "+" Is used to indicate "public", which is visible to all packages.
- "#" Is used to represent "protected". Only the sub-packages of this package can be visible.
- "-" Is used to indicate "private", which is invisible to outsourcing.
8. Principle of creating a package chart
- Minimize dependencies between packages, minimize the number of public and protected elements in each package, and maximize the number of private elements in each package.
- During modeling, circular dependencies between packages should be avoided, that is, mutual dependencies cannot be included. In this case, analysis should be performed:
- The unit of test should be package
- Try to include similar elements in a package.
9. Relationship between packages
- Dependency: changes to the definition of one element may cause changes to another element. The dependency relationship of the package is also indicated by a dotted line. The dotted line arrow points from the dependency package to the dependent package.
Note: The package marked with {Global} is a universal package, indicating that all other packages in the system depend on this package.
- Generalization: express the general and special relationships between things. If there is a general relationship between the two packages, it means that the special packages must follow the interface of the general package. {Abstract} indicates that it defines an Interface
10. Use the UML package diagram
- Each package should be composed of elements that are close to each other in terms of concept and semantics;
- Find elements that should be marked as public for each package, but should be as few as possible;
- Generally, the default "use" constructor is used to clarify the "import" constructor when ing to programming;
- Consider using generalization to model special packages.
- When expressing this model, note that only the elements that play a core role on each package are marked. In addition, you can also identify the document tag value of each package to make it clearer.
Modeling the architecture (ProgramHierarchical) is a more meaningful use of the UML package diagram. Architecture is the core logical structure of a software system.
Common architecture modes include hierarchy, MVC, pipeline, blackboard, and microkernel. In application software, hierarchy and MVC
A package chart is a tool that keeps the system architecture concise and clear. So, if you cannot compress the class image of the entire system to an A4 paper, you should use the package diagram..