非控制库 DLL 何时应显示窗口和其他 GUI 元素?
我相信这主要适用于放入 DLL 中的自定义对话框,但我确信还有一些我没有想到的异常情况。 DLL(也许除了控件库之外)是否有理由显示对话框、弹出窗口或其他 GUI 元素?我发现它通过绕过开发人员并将决策直接传递给用户来剥夺使用该库的开发人员的控制权,但是在某些情况下这可能是有效的设计吗?或者说这真的是糟糕的设计吗?
I believe this mostly applies to custom dialog boxes being put into DLLs, but I'm sure there are some outlying situations I haven't thought of. Is there ever a reason for a DLL (besides perhaps a Control Library) to display dialog boxes, popups or other GUI elements? I see that it takes away control from a developer using that library, by circumventing the developer and passing the decision directly to the user, but are there situations where this might be a valid design? Or is it strictly bad design?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为什么会不好呢?
显然,如果应用程序的非 GUI 层(例如数据抽象层或业务逻辑)尝试直接显示 UI 元素,那会很糟糕,因为这与分层架构相矛盾并限制了组件的重用。
然而,dll 不一定对应于逻辑或功能应用程序层,它是一个部署单元,可以包含从资源到代码到图形元素的任何内容。事实上,您可能希望将业务逻辑和 GUI 捆绑在单个 dll 中,例如,当您创建和部署应用程序扩展时。
Why would it be bad?
Obviously, it would be bad if non-GUI layers of your application such as a data abstraction layer or business logic would try to display UI elements directly because this contradicts the layered architecture and limits the reuse of components.
However, a dll does not necessarily correspond to a logical or functional application layer, it is a deployment unit that can contain about anything from resources to code to graphical elements. In fact, you might want to bundle business logic and GUI in a single dll, e.g. when you create and deploy an application extension.
我相信使用异常机制是最好的方法。
I believe that using the exception mechanism is the best way to go here.