|
马上注册,结交更多同行朋友,交流,分享,学习。
您需要 登录 才可以下载或查看,没有帐号?注册
x
What Are Components and Interfaces?
A component is a reusable object provided in a binary form that can be instantiated and used by client applications to stand for a real object, such as a mathematical surface or a solid feature, or a software object, such as dialog box or an end user command, or finally a set of services, such as a model checker or a stress analyzer. A CAA component is modeled using a class or several classes linked together to provide the component type and the component behaviors.
An interface represents either the type or the behavior, or a part of the behavior, of the implementing component. To allow for this, the interface is made of a set of operations that the implementing component is supposed to perform. When you get an interface pointer to a given component, you get in fact a handle to the component that enables you to request this component to behave accordingly, that is, to perform some of these operations. You can also ask the component to return another handle, that is, a pointer to another interface it implements, and you can thus skip from one handle to another, depending on what you want the component to do.
An interface is also a contract between the interface designer, the component developer, and you, as a client application programmer. This contract includes the interface name and specifications, such as the interface mission, the operations, their signatures and purposes, and the compliance of the component to these specifications. This should not change with the time. Only additions to the specifications are allowed.
The main advantage of interfaces is to enable client applications to use components using a standard and lasting protocol, hiding the implementation details and allowing the components to change with no impact on the client applications. In addition, this standard protocol hides the actual component location and makes the client application independent from the way the component is actually created and accessed, in the same process or in another process, on the same machine or on another machine.
The handle to the component is a pointer to an interface that the component implements, that is, for which the component provides the code of the methods performing the operations.
The interfaces are shown on the following figure as plug-in jacks used by clients to plug to the component as if it were an electronic component, following the UML notation and the way used by Microsoft to graphically represent interfaces in different publications.
As an example, imagine you are writing a client application which deals with points in a 2D space. We can assume that the what we expect from a 2D point is summarized in the following figure of a point component you will use by means of the interfaces it implements.
This point component has a type interface and three behavioral interfaces:
it is a point thanks to the CATIPoint interface that provides methods to get and set its coordinates
it behaves as a movable object by means of the CATIMove interface with which you translate or rotate it
it behaves as a graphic object due to the CATIAttributes interface to manage its color, associated symbol, and pickability
it behaves as a displayable object through the CATIDraw interface to draw it on the screen.
Note that the last three interfaces could be shared by other geometric components, such as the 2D line or the 2D circle, and would be of course implemented differently for these components. |
|