Skip to Content
Design Patterns Explained: A New Perspective on Object-Oriented Design
book

Design Patterns Explained: A New Perspective on Object-Oriented Design

by Alan Shalloway, James R. Trott
July 2001
Beginner to intermediate
368 pages
6h 52m
English
Addison-Wesley Professional
Content preview from Design Patterns Explained: A New Perspective on Object-Oriented Design

Solving with Special Cases

Given the two different CAD/CAM systems described in Chapter 3, “A Problem That Cries Out for Flexible Code,” how do I build an information-extraction system that will look the same to a client object regardless of which CAD/CAM system that I have?

In thinking how to solve this problem, I reasoned that if I can solve it for slots, I can use that same solution for cutouts, holes, etc. In thinking about slots, I saw that I could easily specialize each case. That is, I'd have a Slot class and make a derivation for Slots when I had the V1 system and another derivation when I had a V2 system. I show this in Figure 4-1.

Figure 4-1. The design for slots.

I complete this solution by extending it for each of the feature types, ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Design Patterns Explained: A New Perspective on Object-Oriented Design, Second Edition

Design Patterns Explained: A New Perspective on Object-Oriented Design, Second Edition

Alan Shalloway, James R. Trott
Design It!

Design It!

Michael Keeling

Publisher Resources

ISBN: 0201715945Purchase book