应用程序的正确 .NET DLL 结构 [英] Proper .NET DLL structure for app

查看:23
本文介绍了应用程序的正确 .NET DLL 结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

...如果有这样的事情.这是在 .NET 应用程序中构建 DLL/引用的两种方法的图像:http://www.experts-exchange.com/images/t80668/compArch.png.该应用程序可以是一个网站(在这种情况下是这样)或一个 winform.每个框代表一个 DLL.对于 winform 应用程序,只需将webcontrols"替换为winformcomponents"即可.

...if there is such a thing. Here's an image of two approachs for structuring DLLs/references in a .NET application: http://www.experts-exchange.com/images/t80668/compArch.png. The app can be a website (it is in this case) or a winform. Each box represents a DLL. For the winform app, just replace "webcontrols" with "winformcomponents".

第一个(顶部)图像是我喜欢的.您可能希望扩展某些"基本 Web 控件并直接使用其他控件.第二张图片使您可以通过界面扩展任何 Web 控件.对我来说这似乎有点矫枉过正,因为您可能只想使用已经存在的内容而无需修改.哪个更好,有哪些优点/缺点?

The first (top) image is what I like. You might want to extend "some" of the base web controls and directly use others. The 2nd image makes you extend any web controls via interface. To me that seems overkill since you may want to simply use what is already there without modification. Which is better and what are the advantages/disadvantages?

第一个图像将最低的公共结构(异常、文件IO、常量等)放入 common.dll 中.第二张图片将应用程序业务逻辑和公共逻辑放在一个 DLL 中.哪个更好,每种方法的优点/缺点是什么?

The first image puts the lowest common constructs(exceptions, fileIO, constants, etc) into a common.dll. The 2nd image puts app business logic and common into one DLL. Which is better and what are the advantages/disadvantages of each apporach?

推荐答案

拥有大量引用通常很糟糕,因为加载 DLL 的成本不可忽略.它可能没有那么优雅,但是减少模块可以提高性能.正如在我们的工艺中一样,您必须在完全模块化的优雅和性能的严酷现实之间找到平衡.和我们的工艺一样,在开始分析以衡量应用程序的性能之前,您不会知道什么是平衡.

Having lots of references is usually bad because loading DLL's has a non-negligble cost. It's not as elegant perhaps, but having fewer modules improves your performance. As so often in our craft, you have to find the balance between elegance of total modularization and the harsh reality of performance. And as usual in our craft, you won't know what balance is until you start profiling to measure the performance of your application.

这篇关于应用程序的正确 .NET DLL 结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆