Page 201 -
P. 201
184 Chapter 7 Design and implementation
WeatherStation WeatherData
identifier airTemperatures
groundTemperatures
reportWeather( ) windSpeeds
reportStatus( ) windDirections
powerSave(instruments) pressures
remoteControl(commands) rainfall
reconfigure(commands)
restart(instruments) collect( )
shutdown(instruments) summarize( )
Ground Anemometer Barometer
Thermometer
an_Ident bar_Ident
gt_Ident windSpeed pressure
temperature windDirection height
get( ) get( ) get( )
Figure 7.6 Weather test( ) test( ) test( )
station objects
Figure 7.3. In this case, I use a single object class to encapsulate all of these
interactions, but in other designs you could design the system interface as sev-
eral different classes.
2. The WeatherData object class is responsible for processing the report weather
command. It sends the summarized data from the weather station instruments to
the weather information system.
3. The Ground thermometer, Anemometer, and Barometer object classes are
directly related to instruments in the system. They reflect tangible hardware
entities in the system and the operations are concerned with controlling that
hardware. These objects operate autonomously to collect data at the specified
frequency and store the collected data locally. This data is delivered to the
WeatherData object on request.
You use knowledge of the application domain to identify other objects, attributes,
and services. We know that weather stations are often located in remote places and
include various instruments that sometimes go wrong. Instrument failures should be
reported automatically. This implies that you need attributes and operations to check
the correct functioning of the instruments. There are many remote weather stations
so each weather station should have its own identifier.
At this stage in the design process, you should focus on the objects themselves, with-
out thinking about how these might be implemented. Once you have identified the
objects, you then refine the object design. You look for common features and then
design the inheritance hierarchy for the system. For example, you may identify an
Instrument superclass, which defines the common features of all instruments, such as an
identifier, and get and test operations. You may also add new attributes and operations to
the superclass, such as an attribute that maintains the frequency of data collection.