Objectives
With regard to actual software development, it is important
to develop a style of class design that avoids errors and improves
maintenance and reuse.
In this section a number of metrics are introduced that may be
used to establish quantitative measures of object-oriented
design.
Also formal evaluation criteria for these metrics are discussed,
which give a guideline for the interpretation of the outcome
of applying the metrics to actual designs.
The Law of Demeter provides a rule by which to organize
and reduce dependencies between classes.
Its underlying intuition is to avoid the visibility
of objects embedded in other objects.
In addition, we will discuss some guidelines
for individual class design.
Points to emphasize
- metrics -- objects, attributes, communication
- the Law of Demeter -- ignorance is bliss
- guidelines -- individual class design
Hints
The formal definition of the metrics and the proofs concerning
their behavior under the evaluation criteria given are in itself
not very difficult, but may (with respect to the
experience of your audience) be somewhat hard to swallow at first sight.
Questions
- What metrics can you think of for object-oriented design?
What is the intuition underlying these metrics?
- What evaluation criteria for metrics can you think of?
Are these sufficient for applying such metrics in actual software
projects? Explain.
- Give a formal definition of the following metric:
WMC, DIT. NOC, CBO, RFC and LOC.
Explain their meaning from a software engineering viewpoint.
- What would be your rendering of the Law of Demeter?
Can you phrase its underlying intuition? Explain.
- Define the notions of client, supplier and acquaintance.
What restrictions must be satisfied to speak of
a preferred acquaintance, and a preferred supplier?
Comments
This section must be regarded as a starting point
for further exploration and research.
One can think of incorporating metrics in a browsing
tool.
More importantly, however, are empirical results with regard
to the validity of these metrics.
You may consult [LH89] for a more detailed treatment
and more examples of class transformations.
You may also think of additional examples
to convince students of the fact that
ignorance is bliss. Is that a fact?