Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UML-包图 #7

Open
luhui opened this issue Jun 11, 2019 · 0 comments
Open

UML-包图 #7

luhui opened this issue Jun 11, 2019 · 0 comments
Labels
UML UML 相关的知识

Comments

@luhui
Copy link
Owner

luhui commented Jun 11, 2019

概念

Package diagram is UML structure diagram which shows structure of the designed system at the level of packages. The following elements are typically drawn in a package diagram: package, packageable element, dependency, element import, package import, package merge.

包图是从包的层级来对系统进行抽象描述。所谓包(package)是指一个命名空间(namespace),用于组织语义上相似的、可能会因为业务变动而一起变动的元素。因此相对于类图来说,包图是更高层次的抽象。
一些语言天然的拥有包的概念,比如 c++的 namespace,java 的 package 等。对于前端工程来说,我们可以定义一个文件夹为一个包。

使用场景

通常我们使用包图来对复杂的类图进行抽象,把含义相似的类组织在同一个包里,然后从包的层面来描述业务关系。因此包图适用于描述复杂的业务场景(会出现很多相似类、或者可能会派生很多相似类的场景)的逻辑关系,或者用于表达领域模型,如 MVC,MVVM 等分层设计的表达。

包图元素

包图的元素很少,就是包与依赖关系。因为包是一个命名空间,因此它不像类图一样,可以有很多种的关系,通常情况下我们只需要声明包与包之间的依赖关系即可,不需要像官网一样,为每一种依赖关系明确具体的场景。
包图元素

总结

包图可以理解为一个独立的命名空间、组织,是系统高度抽象的一个模型。包图主要用于建模,并不完全代表代码的表现形式。

思考题

我们在 #4 讲到了组件图,那么什么时候用组件图,什么时候合适使用包图呢?他们之间可以相互替换吗?

@luhui luhui added the UML UML 相关的知识 label Jun 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
UML UML 相关的知识
Projects
None yet
Development

No branches or pull requests

1 participant