contents  
previous
D. Restructuring and optimization activities
Here are several ways in which restructuring and optimization
at an object/class level can be employed in order to produce
a superior final design:
- Splitting a class into several smaller classes to increase
coherence, assuming that this can be done without introducing
too much coupling.
- Collecting several classes into a single class to reduce coupling,
assuming this leads to a highly coherent class.
- Throw away insignificant classes and replace these with simple
attributes and associated methods inside other classes. (However, if
the same simple attribute now needs to be maintained inside different
classes, there could be a data intergrity issue to consider now.)
- Use an appropriate inheritance hierarchy to better organize
classes and promote opportunities for code reuse. (But there is
a substantial potential downside to casual "implementation" inheritance,
as you are asked to consider in HW exercise. Several things need to be
said here.)
- Use design patterns, like the Bridge Pattern, to add flexibility
and opportunity to accommodate future changes.
- Find satisfactory ways to implement one-to-many and many-to-many
association.
- Find satisfactory ways to implement n-ary association. (By the way,
my earlier Teacher-Course-Student example was not a "pure" ternary
association. Since each course is taught by a single teacher, it makes
better sense to hook up binary associations between Teacher and Course,
and between Course and Student.)
- Use proxies and/or data caching for greater efficiency in the presence
of data transmission and computational time delays.
- Add extra methods and operations, or rearrange existing ones, when
doing so means fulfilling a performance requirement. This can result in
extra coupling and so has its downside. Look for ways to achieve
the goals while controlling the coupling issue.
next