Module and Component

来源:互联网 发布:下载英语听力软件 编辑:程序博客网 时间:2024/05/17 01:10

Module和Component是软件设计和开发中经常用到,又是比较容易搞混得概念。

 

RUP的4+1view也是是软件(架构)设计中经常用到了,其中包含了logical view 和 development view,一般分别用class diagram 和 component diagram来描述。 wiki对4+1view的定义如下: 

  • Logical view : The logical view is concerned with the functionality that the system provides to end-users. UML Diagrams used to represent the logical view include Class diagram, Communication diagram, Sequence diagram.
  • Development view : The development view illustrates a system from a programmer's perspective and is concerned with software management. This view is also known as the implementation view. It uses the UML Component diagram to describe system components. UML Diagrams used to represent the development view include the Package diagram.  
  • Process view : The process view deals with the dynamic aspects of the system, explains the system processes and how they communicate, and focuses on the runtime behavior of the system. The process view addresses concurrency, distribution, integrators, performance, and scalability, etc. UML Diagrams to represent process view include the Activity diagram.
  • Physical view : The physical view depicts the system from a system engineer's point-of-view. It is concerned with the topology of software components on the physical layer, as well as communication between these components. This view is also known as the deployment view. UML Diagrams used to represent physical view include the Deployment diagram.
  • Scenarios : The description of an architecture is illustrated using a small set of use cases, or scenarios which become a fifth view. The scenarios describe sequences of interactions between objects, and between processes. They are used to identify architectural elements and to illustrate and validate the architecture design. They also serve as a starting point for tests of an architecture prototype. UML Diagram(s) used to represent the scenario view include the Use case diagram.

之前写设计文档时,更多的精力都花在描述这两个view上面,而没有很认真地思考过Module和Component的区别,只有一个比较模糊的概念来区分两者,即认为:两者的区别只在颗粒度上,component 大于/包含 module,经常把class的design归为module design放在logical view里面, package或者function block 的design归为component design放在component view里面。

 

最近翻了一下"Documenting Software Architecture",发现书中对Module和Component有如下定义:

A module tends to refer first and foremost to a design-time entity. ... information hiding as the criterion for allocating responsibility to a module.
A component tends to refer to a runtime entity. ... The emphasis is clearly on  the finished product and not on the design considerations that went into it.

In short, a module suggests encapsultion properties, with less emphasis on the delivery medium and what goest on at runtime. Not so with components. A delivered binary maintains its "separatenss" throughout execution. A component suggests independently deployed units of software with no visibility into the development process.

 

可见Module更关注于静态的设计,比如class, function;而Component更关注于动态以及交互(接口)的设计,它既包含了Development View 里的element,也应该包含Process View里面的element.

 

原创粉丝点击