Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007
Fall01 Final Exam Review: Design an Alarm System
Back to Final Exam Review - Fall2001
/ 1 \ \ \
/ \ \ AlertSender
/ hasA \ Sprinklers
I would make a central alarm system class, System. This will have many Alarms, which Audio and Fire inherit. There will be a getTrigger method that will receive a message that an alarm has sounded.
The Alarms will have a list of contacts, so it can tell the System who to contact when an alarm is triggered, as well as its vicinity, so the System knows where the alarm is. There should also be startAlarm, stopAlarm methods.
The System will have, in addition to the Alarms, an AlertSender that contacts the respective authorities according to the contacts list and vicinity received from the Alarm. There is a sendMessage method in the System that will handle this.
The System will also have Sprinklers and AudioAlarms. I believe these should be under System and NOT the fire/audio Alarm, because the sprinklers/buzzers should be able to be started and stopped from the main system, not just an individual vicinity or Alarm.
?? The generalization-specialization methods are the Fire/Audio alarms to Alarm.
?? The part-whole relationships are the Alarms to the System.
To implement the View/Model communication, I would connect many Views (AlarmStatusView) to the model (System). In this way, all views, either individual or whole, could be connected to the entire system, and would not be dependent on one location.
Now, realizing that there is more than one location, I would need a new class, Location. Uh, so I guess I would not be adding my views to the System, but rather to each Location. The System would have many Locations. Each Alarm added to the System would also add it to its respective Location according to its vicinity. Each Location would default its view to the current vicinity. Each Location could also switch views.
Since the Alarms are connected to the System, the System would update the Locations and their views. When any alarm was triggered, it could either update all views or just the Location's view depending on the vicinity of the Alarm triggered.
|Could I have a bit more detail on how alarms update views? Remember, PLEASE think MVC on this... Mark Guzdial|
For this system seems to be a god class which is bad, however this seems to be the only real way to implement this. Is this a cause were a god class is good OOD?
I'm guessing the alarms update views as so. The alarm gets tripped by one of the various events that can trip it. For this one we'll say burgalar. Then the alarm screams out that it's been tripped and send out a chagned call with a reference to itself as a parameter.. The System, since it's a dependent of alarm, recieves this update then the System ask that alarm what happened. Then ti will take the appropriate action based on what the alarm says.
This seems good, what if you connect it to the nearest police station...
Kiss my ass
Smythy is a queer
adam is a mong
u r a cock sucker!!!!!
Link to this Page