掌握控制器,它真的需要UI存在吗?

发布于 2024-08-27 08:53:03 字数 320 浏览 2 评论 0原文

我有一个可以处于多种状态的域模型,如果这些状态超出给定范围,域应该自动做出反应。

例如,我有一辆由多种部件组成的汽车,这些部件具有测量

发动机转速计数器和

油箱温度的能力,

有一个 CarStateController 是合理的,它可以观察发动机和油箱,如果这些状态超出范围,即发动机温度高于范围,打开发动机风扇。

没有 UI,(您可能会说它会在仪表板上显示指示灯,但在本例中它不会)这是 GRASP 控制器模式的有效使用吗?如果不是,这个 CarStateController 叫什么?

或者我完全错过了重点,这应该是状态模式?

I have a Domain model which can be in multiple states, and if these states go out of a given range the domain should 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

乱了心跳 2024-09-03 08:53:03

您是否考虑过将这个问题发送给 Craig Larman,他是 GRAS 模式的创造者???他可能会也可能不会回答你的问题。我在《应用 UML 和模式》一书中理解外观控制器的方式是,外观控制器不应该“维护有关系统或域的重要信息”PG 311 第三版。否则你会得到一个臃肿的控制器。听起来您需要一个名为“调节器”的附加域对象,它监视其他域对象并在级别过高或过低时做出反应。我意识到我没有讨论您的状态模式,因为我不熟悉它。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文