An airplaneās onboard software system includes an AdminController object responsible for monitoring:
Multiple subsystems (navigation, engines, cabin sensors, cockpit display) must access this controller to report data or request decisions.
The system must guarantee that only one AdminController instance exists at any time.
What problems might occur if two AdminController objects exist?
Which object would the sensors talk to? Both?
Could conflicting decisions be made?
Click the button to see the AdminController class.
In software design, when we need to guarantee exactly one instance of a class and provide global access to it, we use a pattern called the singleton.
Look again at the AdminController class above. There is no way to stop other classes creating AdminController instances.
Hance, more than 1 instance can exist, which is undesireable in this scenario.
The following video will introduce the ingenious way that a single instance of a class can be created and have global access to all other parts of the program/system.
Complete the worksheet as you follow the video.
singleton
static
class variable
private
data hiding
encapsulation/p>
instance