23.07.2012 Views

Design Patterns Explained

Design Patterns Explained

Design Patterns Explained

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 4 • A Standard Object-Oriented Solution 63<br />

In Figure 4-3, I have added a few of the methods that are needed by<br />

the features. Note how they differ depending upon the type of<br />

feature. This means I do not have polymorphism across features.<br />

This is not a problem, however, since the expert system needs to<br />

know what type of feature it has anyway. This is because the expert<br />

system needs different kinds of information from different types of<br />

features.<br />

This brings up the point that I am not so interested in polymorphism<br />

of the features. Rather, I need the ability to plug-and-play<br />

different CAD/CAM systems without changing the expert system.<br />

What I am trying to do— handle multiple CAD/CAM versions transparently—<br />

gives me several clues that this solution is not a good<br />

one:<br />

Redundancy amongst methods— I can easily imagine that the<br />

methods that are making calls to the V1 system will have many<br />

similarities between them. For example, the Vlgetx for Slot<br />

and Vlgetx for Hole will be very similar.<br />

Messy— This is not always a good predictor, but it is another factor<br />

that reinforces my discomfort with the solution.<br />

Tight coupling— This solution has tight coupling because the<br />

features are related to each other indirectly. These relationships<br />

manifest themselves as the likely need to modify all of the features<br />

if the following occurs:<br />

- A new CAD/CAM system is required.<br />

- An existing CAD/CAM system is modified.<br />

Low cohesion— Cohesion is fairly low since methods to perform<br />

core functions are scattered amongst the classes.<br />

This solution satisfies<br />

one goal: a common<br />

API<br />

but contains many<br />

challenges

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!