Section 5.11 Problem Solving = Representation + Action
As 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 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 this 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 our science and technology would be where they are today if our civilization had to rely forever on the Roman way of representing numbers!
Principle 5.11.1. EFFECTIVE DESIGN: Representation and Action.
Representation (data) and action (methods) are equally important parts of the problem-solving process.
You have attempted
of
activities on this page.