Design Patterns Explained Java Code Examples – Chapter 1: The Object-Oriented Paradigm

Chapter 1: The Object-Oriented Paradigm
Code Examples

Example 1-1: Using Modularity to Contain Variation


For example, in Step 4c on page 4, where I “Call the appropriate function that will display the shape, giving it the shape’s location,” I could write a module like that shown in Example 1-1.

function: display shape
input: type of shape, description of shape
    switch (type of shape)
        case square: put display function for square here
        case circle: put display function for circle here