对向 UI 发送状态消息的方法有何批评?

发布于 2024-09-30 04:53:42 字数 424 浏览 3 评论 0原文

我们正在编写一个在 Excel 2002 中托管的应用程序(唉)。一个需求是,在某些操作过程中,我们从业务层向用户提交进度消息。但是,这些消息可以显示在多个站点上,一个是 Excel 状态栏,另一个是表单上的标签,将来可能还会显示其他站点。在某些情况下,我们希望仅将消息发布到 Excel 状态栏,在其他情况下,仅将消息发布到表单上的标签,而在其他情况下,两者都发布。

目前,我们有一个消息“中心”,业务逻辑可以向其发布状态消息。 Excel 状态栏和表单标签都观察该中心,如果发布任何消息,两者都会拦截消息并显示它们 - 类似于通过邮局的群发邮件,发件人不关心目的地。

第一:这是普遍接受的模式吗?

第二:业务层了解其需要将消息发布到的目的地是否是谨慎的做法?尽管通过使用邮局业务层与 UI 相对解耦,但您对向业务层注入本质上的地址/目标/目的地信息有何看法?

谢谢。

We are writing an application hosted in Excel 2002 (groan). One requirement is that, during certain operations, we submit progress messages to the user from the business layer. However, these messages can be displayed at multiple sites, one being the Excel status bar, and another being a label on a form, and possibly others in the future. In some situations, we desire to only post the message to the Excel status bar, in others, just the label on the form, and in others, both.

Currently, we have a message "hub" to which business logic can post status messages. The Excel status bar and also the form label both observe this hub, and if any messages are posted, both intercept the messages and display them- similar to mass mailings via a post office, where the sender is unconcerned with the destination.

First: Is this a generally accepted pattern?

Second: Would it be prudent for the business layer to have knowledge of the destination to which it needs to post a message? Even though the business layer is relatively decoupled from the UI through the use of the post office, what is your opinion of imbuing the business layer with, essentially, address/target/destination information?

Thanks.

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

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

发布评论

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

评论(1

窗影残 2024-10-07 04:53:42

如果您想坚持使用传统模式来解决此类问题,那么您将需要研究模型-视图-控制器 (MVC) 设计模式。该模式的目的是将业务逻辑与 GUI 分离。它允许一种模型(业务逻辑)驱动多个不同的 GUI。

If you want to stick with the conventional pattern for this type of problem then you will want to look into the Model-View-Controller (MVC) design pattern. The purpose of the pattern is to decouple business logic from the GUI(s). It allows for one model (business logic) to drive multiple different GUIs.

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