And the thermostat may have switched the compressor off
of components, each of which is represented as an instance of a class of component. The function of each component is defined within its class definition. The structure of a device is defined by links between the instances of components that make up the device. The device may be in one of several states, for example a refrigerator door may be open or closed, and the thermostat may have switched the compressor on or off. These states are defined by setting the values of instance variables.
Object-oriented programming is particularly suited to device modeling because of this clear separation of function, structure, and state. These three aspects of a device are fundamental to understanding its operation and possible malfunctions. A contrast can be drawn with mathematical modeling, where a device can often be modeled more easily by considering its overall activity than by analyzing the component processes.
• conduit — transports substances between other functional primitives.
A fifth class, sensor, may be added to this list. A sensor object simply displays the value of its input.
Regulator | Reservoir | Conduit |
---|
|
Electrical | Fluid | Electrical | Fluid | Food |
|
Fluid |
---|
transformer | regulator | reservoir | reservoir | conduit | ||||
---|---|---|---|---|---|---|---|---|
|
|
Valve | Cabinet | Tube |