Considerations for ports

Ports are interaction points through which objects can send or receive messages (primitive operations, triggered operations, and events).

Ports in UML have a type, which in IBM® Rational® Rhapsody® is called a contract. A contract of a port is like a class for an object.

If a port has a contract (for example, interface I), the port provides I by definition. If you want the port to provide an additional interface (for example, interface J), then, according to UML, I must inherit J (because a port can have only one type). In the case of Rational Rhapsody, this inheritance is created automatically once you add J to the list of provided interfaces (again, this is a port with an explicit contract I). According to the UML standard, if I and J are unrelated, you must specify a new interface to be the contract and have this interface inherit both I and J.

Implicit port contracts

Some found that enforcing a specification of a special interface as the contract of the port to be artificial, so Rational Rhapsody provides the notion for an implicit contract This means that if the contract is implicit, you can specify a list of provided and required interfaces that are not related to each other, whereas the contract interface remains implicit (no need to explicitly define a special interface to be the contract for the port in the model).

Working with implicit contracts has pros and cons. If the port is connected to other ports that provide and require only subsets of its provided and required interfaces, it is more natural to work with implicit contracts. However,, if the port is connected to another port that is exactly "reversed" (see the check box in the Features window for the port) or if other ports provide and require the same set of interfaces, it makes sense to work with explicit contracts. Working with the explicit contracts is like specifying objects separately from the classes, or objects with implicit classes in the case when only a single object of this type or class exists in the system.

Rapid ports

Rapid ports are ports that have no provided and required interfaces (which means that the contract is implicit, because a port with an explicit contract, by definition, provides a contract interface). These ports relay any events that come through them. The notion of rapid ports is Rational Rhapsody-specific, and enables users to do rapid prototyping using ports. This functionality is especially beneficial to users who specify behavior using statecharts - without the need to elaborate the contract at the early stages of the analysis or design.


Feedback