I have a Domain model which can be in multiple states, and if these states go out of a given range the domain s开发者_运维百科hould automatically react.
For example I have a Car which is made of multiple things which have measurements
the Engine - Rev counter and Temperature
the Fuel Tank - capacity
It is plausible to have a CarStateController, which observes the engine and the tank, and if these states go out of range i.e. the engine temperature goes above range, turn the engine fan on.
There is no UI, (you could argue it would show a light on the dash board, but for this case it does not) is this a valid use of a GRASP controller pattern? if not what is this CarStateController Called?
Or have I completely missed the point and this should be the State Pattern?
Have you thought about sending this question to Craig Larman, the one who coined the GRAS Patterns??? He may or may not respond to your question. The way I understand Facade controller in his book APPLYING UML and Patterns, a facade controller should not 'maintain significant information about the system or domain' PG 311 3rd edition. Otherwise you get a bloated controller. Sounds like you need an additional domain object called a 'Regulator' that monitors other domain objects and reacts when levels are too high or too low. I realize I am not addressing your State pattern that's because I am not familiar with it.
精彩评论