What is a model? A model is a simplified representation of a complex entity.
A model is used to help understand and reason about an entity. It abstracts
important details and hides unnecessary information. An activity you have
been doing all your life!
Model train
Model plane
Stock market simulator
Your class schedule
Different models occur in various places in programming
The "real world" may be real or hypothetical
Context plays a key role in any model
Getting models "right" is hard work in programming! Involves proper training,
experience.
Problems that occur in software result of mistakes in models (think of
"telephone game")
Some important characteristics
Model elements represent complex things
Elements have consistent behavior.
Elements group into categories based on behavior.
Actions external to model cause behavior to take place.
Example: A Model for Air Traffic Control
Suppose you are creating a model for air traffic control at Greenville-Spartanburg
Airport.
Map - to represent geographical location of airplanes
Rectangles - to represent terminals (A and B)
Color-coded Lights - to represent airplanes and their altitude
Objects, Behavior and Classes
Objects, classes, and behavior
Objects - In Java, objects represent model elements
Behavior - In Java, behavior is represented by actions that can
take place on objects
Classes - In Java, classes represent categories of elements (objects).
Defines behavior for objects.
Instance - In Java, an object is an instance of a class
Reference - In Java, a reference is a name of an object
Identifying objects, classes, and behavior in our air traffic control model
Objects - various planes (US1234, CO89, ...) , terminals A and B,
SC map, Eastern seaboard map
Behavior - take off, land, park at terminal, adjust altitude, check
terminal, position on map
Classes - plane class, terminal class, map class
Instance - a plane object is an instance of the plane class, which
defines the behavior for planes, such as take off, adjust altitude, etc.
Reference - US1234 is a reference to a plane object
Sending Messages To Objects
To make an object perform a behavior, we send it a message. Sending a message
requires three things:
a reference to the object
the name of the behavior
additional information needed for the object to do its job