patterns in a security alarm system (sas) agenda domain model domain model the patterns the patterns...
TRANSCRIPT
Patterns in a Patterns in a Security Alarm System (SAS)Security Alarm System (SAS)
AGENDAAGENDA
Domain ModelDomain Model The PatternsThe Patterns
– IteratorIterator– ObserverObserver– Abstract FactoryAbstract Factory– SingletonSingleton
Observable Item
SensorObserves Triggers
Notifies
Room TempDoor Window
Break In Thermostat Motion Detector
Magnetic Switch Smoke Sensor
Open Event Temp EventBreak Event Smoke Event
Monitoring Co. Police OwnerFire
EVENT Attach(Observer)Detach(Observer)Notify()Trigger()
Monitoring Authority
Notify()
Security Alarm System (SAS)Domain Model
ITERATOR PATTERN
Applicability Applicability
Access an aggregate object's Access an aggregate object's contents without exposing its contents without exposing its internal representation.internal representation.
Support multiple traversals of Support multiple traversals of aggregate objects. aggregate objects.
ITERATOR PATTERN
Abstract List CreateIterator()Count()AppendItem()RemoveItem()
ITERATOR PATTERN in SAS
Sensor List
Zone List
Sensor
Iterator
First()Next()IsDone()CurrentItem()
SensorIterator
ZoneIterator
Zone
Applicability Applicability
When a change to one object requires When a change to one object requires changing others, and you don't know changing others, and you don't know how many objects need to be changed.how many objects need to be changed.
When an object should be able to notify When an object should be able to notify other objects without making other objects without making assumptions about which objects they assumptions about which objects they are. are.
OBSERVER PATTERN
OBSERVER PATTERN
EVENT Attach(Observer)Detach(Observer)Trigger()
OBSERVER PATTERN in SAS
Open Event Temp EventBreak Event Smoke Event
Monitoring Co. Police OwnerFire
observers
for all o in observers
o.Notify()
Monitoring Authority
Notify()
Applicability Applicability
A system should be independent of A system should be independent of how its products are created, how its products are created, composed, and represented. composed, and represented.
A system should be configured with A system should be configured with one of multiple families of products.one of multiple families of products.
ABSTRACT FACTORY PATTERN
ABSTRACT FACTORY PATTERN
EVENT Attach(Observer)Detach(Observer)Trigger()
ABSTRACT FACTORY PATTERN in SAS
Open Event Temp EventBreak Event Smoke Event
Sensor
Break In Thermostat Motion Detector
Magnetic Switch Smoke Sensor
Sensor Factory CreateSensor()CreateEvent()
Door Sensor
Window Sensor
Applicability Applicability
There must be exactly one instance There must be exactly one instance of a class, and it must be accessible of a class, and it must be accessible to clients from a well-known access to clients from a well-known access point. point.
SINGLETON PATTERN
SINGLETON PATTERN
SAS <<controller>>
static getInstance()
SINGLETON PATTERN in SAS
return myInstance
static myInstance