Page 177 - DCAP308_OBJECT_ORIENTED_ANALYSIS_AND_DESIGN
P. 177
Unit 14: Steps for Class Design
14.1.4 Design Optimization Notes
The basic design model uses the analysis model as the framework for implementation. The
analysis model captures the logical information about the system, while the design model must
add details to support efficient information access. The inefficient but semantically correct analysis
model can be optimized to make the implementation more efficient, but an optimized system is
more obscure and less likely to be reusable in another context.
The designer must strike an appropriate balance between efficiency and clarity. During design
optimization, the designer must:
1. Add Redundant Associations for Efficient Access: During analysis, it is undesirable to
have redundancy in association network because redundant associations do not add any
information. During design, however, we evaluate the structure of the object model for an
implementation. For that, we have to answer the following questions:
Is there a specific arrangement of the network that would optimize critical aspects of
the completed system?
Should the network be restructured by adding new associations?
Can existing associations be omitted?
The associations that were useful during analysis may not form the most efficient
network when the access patterns and relative frequencies of different kinds of
access are considered. In cases where the number of hits from a query is low because
only a fraction of objects satisfy the test, we can build an index to improve access to
objects that must be frequently retrieved. Analyze the use of paths in the association
network as follows:
Examine each operation and see what associations it must traverse to obtain its
information. Note which associations are traversed in both directions, and which
are traversed in a single direction only, the latter can be implemented efficiently
with one way pointers.
For each operation note the following items:
How often is the operation called? How costly is to perform?
What is the “fan-out” along a path through the network? Estimate the average count
of each “many” association encountered along the path. Multiply the individual
fan-outs to obtain the fan-out of the entire path; which represents the number of
accesses on the last class in the path. Note that “one” links do not increase the fan-
out, although they increase the cost of each operation slightly, don’t worry about
such small effects.
What is the fraction of “hits” on the final class, that is, objects that meets selection
criteria (if any) and is operated on? If most objects are rejected during the traversal
for some reason, then a simple nested loop may be inefficient at finding target
objects. Provide indexes for frequent, costly operations with a low hit ratio because
such operations are inefficient to implement using nested loops to traverse a path in
the network.
2. Rearranging Execution Order for Efficiency: After adjusting the structure of the object
model to optimize frequent traversal, the next thing to optimize is the algorithm itself.
Algorithms and data structures are directly related to each other, but we find that usually
the data structure should be considered first. One key to algorithm optimization is to
eliminate dead paths as early as possible. Sometimes the execution order of a loop must be
inverted.
LOVELY PROFESSIONAL UNIVERSITY 171