Page 174 - DCAP308_OBJECT_ORIENTED_ANALYSIS_AND_DESIGN
P. 174
Object Oriented Analysis and Design
Notes the event and the state of the object. Therefore, the algorithm implementing an operation
depends on the state of the object.
If the same event can be received by more than one state of an object, then the code implementing
the algorithm must contain a case statement dependent on the state. An event sent by an object
may represent an operation on another object. Events often occur in pairs, with the first event
triggering an action and the second event returning the result on indicating the completion of
the action. In this case, the event pair can be mapped into an operation performing the action and
returning the control provided that the events are on a single thread. An action or activity
initiated by a transition in a state diagram may expand into an entire data flow in the functional
model.
Did u know? The network of processes within the data flow represents the body of an
operation.
The flows in the diagram are intermediate values in operation. The designer converts the graphic
structure of the diagram into linear sequence of steps in the algorithm. The process in the data
flow represents sub operations. Some of them, but not necessarily all may be operations on the
original target object or on other objects.
Determine the target object of a sub operation as follows:
If a process extracts a value from input flow then input flow is the target.
Process has input flow or output flow of the same type, input output flow is the target.
Process constructs output value from several input flows, and then the operation is a class
operation on output class.
If a process has input or an output to data store or actor, data store or actor is the target.
14.1.2 Designing Algorithms
Each operation specified in the functional model must be formulated as an algorithm. The
analysis specification tells what the operation does from the view point of its clients, but the
algorithm shows how it is done. The analysis specification tells what the operation does from
the view point of its clients, but the algorithm shows how it is done. An algorithm may be
subdivided into calls on simpler operations, and so on recursively, until the lowest-level operations
are simple enough to implement directly without refinement. The algorithm designer must
decide on the following:
1. Choosing algorithms: Many operations are simple enough that the specification in the
functional model already constitutes a satisfactory algorithm because the description of
what is done also shows how it is done. Many operations simply traverse paths in the
object link network or retrieve or change attributes or links.
Non trivial algorithm is needed for two reasons:
(a) To implement functions for which no procedural specification
(b) To optimize functions for which a simple but inefficient algorithm serves as a
definition.
Some functions are specified as declarative constraints without any procedural definition.
In such cases, you must use your knowledge of the situation to invent an algorithm. The
essence of most geometry problems is the discovery of appropriate algorithms and the
proof that they are correct. Most functions have simple mathematical or procedural
168 LOVELY PROFESSIONAL UNIVERSITY