开发者

When should non-control library DLLs display windows and other GUI elements?

开发者 https://www.devze.com 2023-01-10 10:30 出处:网络
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 Co

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 c开发者_Python百科ircumventing 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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消