0

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.

4

1 回答 1

1

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

于 2010-10-31T23:36:23.250 回答