3.1 Creating Models
Humans are model-builders. We create
models of the world to manage complexity and to help us understand
problems we're trying to solve. You see models all
the time. Maps are models of roadways. Globes are models of the
Earth. Chemical symbols are models of chemical interactions. Atomic
models are representations of the interaction of sub-atomic
particles.
Models are simplifications. There is little point to a model that is
as complex as the object in the problem domain. If you had a map of
the United States that had every rock, blade of grass, and bit of
dirt in the entire country, the map would have to be as big as the
country itself. Your road atlas of the U.S. eschews all sorts of
irrelevant detail, focusing only on those aspects of the problem
domain (e.g., the country's roads) that are
important to solving the problem (e.g., getting from place to place).
If you want to drive from Boston to New York City, you
don't care where the trees are; you care where the
exits and interchanges are located. Therefore, the network of roads
is what appears on the atlas.
Albert Einstein once said: "Things should be made as
simple as possible, but not any simpler." A model
must be faithful to those aspects of the problem domain that are
relevant. For example, a road map must provide accurate relative
distances. The distance from Boston to New York must be proportional
to the actual driving distance. If one inch represents 25 miles at
the start of the trip, it must represent 25 miles throughout the
trip, or the map will be unusable.
A good object-oriented design is an accurate model of the problem you
are trying to solve. Your design choices influence not only how you
solve the problem, but in fact they influence how you think about the
problem. A good design, like a good model, allows you to examine the
relevant details of the problem without confusion.
|