清明时节雨

导航

组件的语义描述

      《OMG UML Superstructure》中对于组件的语义描述一段感觉比较精彩,特翻译如下,不当之处请大家指正。

      一个组件是一个自成体系的单元,它封装了一些分类成员的状态和行为。一个组件制定了其相关的正式契约,这些契约包括它为其客户提供的服务以及它所依赖于系统中其它组建提供的服务,这些通过其提供和要求的接口的形式给出。

      组件是一个可替换单元,它可以在设计时或者运行时被替换,只要替换它的组件满足基于接口一致性的等价功能。只要环境允许组件通过提供和需求的接口形式提出的约定,这个组件就可以满足这个环境中的交互需求。因此,一个系统可以通过增加新的组件来扩展现有的功能。

      组件要求和提供的接口可以体现为结构特征,例如属性和关联;也可以体现为行为特征,例如操作和事件。组件可以直接实现接口,也由其实现分类来完成,或者通过继承这种实现。组件要求和提供的接口可以使用端口来组织,这样可以定义命名组,以便于运行时定位。

      组件的公开属性和操作构成其外部视图(或“黑盒”视图)。不同情况下,类似协议状态机的行为可以定位于接口、端口或者组件本身,这样可以动态的约束操作的调用序列,使得组件的外部视图更加清晰。其它行为一般定位于接口或者连接器,它们主要用于定义写作的组建之间的约定。

      系统中组件之间或者组件和上下文的耦合可以使用组件见接口的依赖关系描述(通常使用结构图)。结构性写作更详细的描述可以使用端口和连接器的组合结构,这可以明确组件之间角色层次或者实例层次的协作。

      相对于外部视图,组件的私有属性和具体功能的实现分类构成其内部视图(或“白盒”视图)。此视图展示了组件的外部行为在其内部是如何实现的。两个视图之间的映射通过依赖关系以及组件内部成员的代理连接器。进一步,交互模型和活动模型可以展示这一映射的更多行为细节。

原文如下:

A component is a self contained unit that encapsulates the state and behavior of a number of classifiers. A component specifies a formal contract of the services that it provides to its clients and those that it requires from other components or services in the system in terms of its provided and required interfaces.

A component is a substitutable unit that can be replaced at design time or run-time by a component that offers equivalent functionality based on compatibility of its interfaces. As long as the environment obeys the constraints expressed by the provided and required interfaces of a component, it will be able to interact with this environment. Similarly, a system can be extended by adding new component types that add new functionality.

The required and provided interfaces of a component allow for the specification of structural features such as attributes and association ends, as well as behavioral features such as operations and events. A component may implement a provided interface directly, or, its realizing classifiers may do so, or they may be inherited. The required and provided interfaces may optionally be organized through port, these enable the definition of named sets of provided and required interfaces that are typically (but not always) addressed at run-time.

A component has an external view (or “black-box” view) by means of its publicly visible properties and operations. Optionally,a behavior such as a protocol state machine may be attached to an interface, port, and to the component itself, to define the external view more precisely by making dynamic constraints in the sequence of operation calls explicit. Other behaviors may also be associated with interfaces or connectors to define the ‘contract’ between participants in a collaboration (e.g., in terms of use case, activity, or interaction specifications).

The wiring between components in a system or other context can be structurally defined by using dependencies between component interfaces (typically on structure diagrams). Optionally, a more detailed specification of the structural collaboration can be made using parts and connectors in composite structures, to specify the role or instance level collaboration between components (See Clause Composite Structures).

A component also has an internal view (or “white-box” view) by means of its private properties and realizing classifiers. This view shows how the external behavior is realized internally. The mapping between external and internal view is by means of dependencies (on structure diagrams), or delegation connectors to internal parts (on composite structure diagrams).

 

posted on 2012-06-24 00:34  学而不思  阅读(324)  评论(0编辑  收藏  举报