5.9. Problem Solving = Representation + ActionAs you have seen in this chapter, designing classes involves a careful interplay between representation (data) and action (methods). Our several modifications to the OneRowNim class illustrate that the data used to represent an object's state can either complicate or simplify the design of the methods needed to solve a problem. We hope that it is becoming clear to you that in writing object-oriented programs, choosing an appropriate data representation is just as important as choosing the correct algorithm. The concept of an object allows us to encapsulate representation and action into a single entity. It is a very natural way to approach problem solving. If you look closely enough at any problem, you will find a close relationship between representation and action. For example, compare the task of performing multiplication using Arabic numerals (65 * 12 = 380) and the same task using Roman numerals (LXV * XII = DCCLXXX). It's doubtful that science and technology would be where they are today if our civilization had to rely forever on the Roman way of representing numbers! Effective Design: Representation and Action
|