Activity:
|
Purpose
|
|
Role: Capsule Designer | |
Frequency: As required, typically occurring multiple times in an iteration, and most frequently in elaboration and construction iterations. | |
Steps |
|
Input Artifacts: |
Resulting Artifacts: |
Tool Mentors: | |
More Information: | |
Workflow Details: |
Capsules are used to define concurrent threads of execution in the system. Capsules may be nested to an arbitrary depth, as well as having associations to design (passive) classes. This activity is performed once for each capsule, including new capsules identified within the scope of this activity.
Consider the responsibilities of the capsule, creating an initial set of port classes. These port classes represent the 'interfaces' to the capsule. Port classes represent the realization of an Artifact: Protocol, which in turn represents a set of in and out signals used to communicate with capsules.
In creating ports, consider the Checkpoints: Protocol to determine whether the Protocol is appropriate. The port should reflect a singular set of related responsibilities; having a similarly scoped protocol enables its re-use across a number of capsules. Once the appropriate protocol is selected, bind the port to the appropriate protocol.
Once the ports are bound to protocols, the external behavior of the capsule must be evaluated and validated. Using either manual walk-through techniques or automated simulation tools, test the behavior of the capsule by simulating the events that will exercise the capsule behavior. Validation will also consider the capsules which interact with the capsule under design. Using automated tools, write stub code within the capsule to allow the ports to be tested. When errors in protocol or port definition, or in capsule responsibilities are detected, make appropriate changes to capsule, port and protocol definitions.
Once the capsule ports and protocols have been validated, define the internal behavior of the capsule. The behavior of the capsule is defined using a statechart diagram, refer to the Guidelines: Statechart Diagram. Other general capsule information can be obtained from Guidelines: Capsule and Checkpoints: Capsules.
First, identify the states in which the capsule can exist. The states must be unique (a capsule cannot be in two states simultaneously) and descriptive. See the appropriate guidelines and checkpoints for more information.
Once states are defined, consider the transitions between states. Transition code should read like high level application pseudo-code, it should consist primarily of real-time operating system service calls e.g., frame services, time services, port operations, capsule operations and passive class operations.
When adding detail code to a Capsule transition:
When defining a Capsule operation:
Based on the capsule state machines, examine the passive classes referenced by the capsule. If there are new requirements on these classes, change requests need to be generated to effect the required changes. If new classes have been identified, the requirements on these classes (most specifically the required operations on them) should be gathered together and the classes should be created. These classes will be further described in the Activity: Class Design.
Capsule inheritance is used to implement generalization-specialization, to make use of polymorphism, to reuse implementation. The key word here is 'implementation' - it is a technique that is used primarily to re-use the internal structure of capsules, not the external behavior of capsules. The primary purpose of Artifact: Protocols is to re-use behavioral definitions, so capsule inheritance should not be used for this purpose.
Inheritance is often misapplied to achieve something that could more easily have been achieved using simpler design techniques.
There are three kinds of inheritance. Listed from lowest complexity (most desirable) to most complex (least desirable), they are:
Structural and behavioral inheritance pose some problems:
Other problems include:
All designs containing structure/behavior have decisions and assumptions built in (either explicit or implicit). The critical question to ask is: are you absolutely sure that decision/assumption will always be valid? If not, what can you do to remove it or make it possible to change?
As a final step, the behavior of the capsule must be evaluated and validated. Using either manual walk-through techniques or automated simulation tools, the behavior of the capsule should be tested by simulating the events that will exercise the capsule behavior. In addition, the internal structure of the capsule should be validated, ensuring that not only the external behavior but also the internal implementation of that behavior is validated. Using automated tools, stub code may need to be written to simulate the implementation of passive data classes and external capsules with which the capsule interacts. Defects detected should be documented and appropriate changes to capsule definitions should be made.
Note that the current RUP representation for Capsules is based on UML 1.5 notation. Much of this can be represented in UML 2.0 using the Concepts: Structured Class.
Refer to Differences Between UML
1.x and UML 2.0 for more information.
Rational Unified Process |