为什么可以选择为业务模块的接口创建单独的类库?
在 wcsf 中,如果我勾选相关的框,则可以使用单独的类库仅用于接口来创建业务模块。
仅仅为接口建立一个单独的类库有什么意义呢? 这不会给我的项目增加不必要的膨胀并在两个类库之间创建高度耦合吗? 将接口存储在存储具体类的类库中会出现什么问题?
谢谢。
In wcsf, it is possible to make a business module with a separate class library just for interfaces, if I tick the relevant box/boxes.
What is the point in having a separate class library just for interfaces? Wouldn't this add unnecessary bloat to my project and create a high coupling between two class libraries? What would be wrong with storing the interfaces in the class library storing concrete classes?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将接口存储在单独的类库中的优点是它实际上解耦了类库的实现和使用。 如果接口带有具体的实现类,那么您将拥有
ImplementingClasses.dll <--- ClientClasses.dll
如果您将接口放入单独的程序集中,则更像是这样:
ImplementingClasses.dll ---> Interfaces.dll <--- ClientClasses.dll
请注意这如何消除客户端代码和实现之间的耦合 - 这将允许您的整个应用程序使用基于配置的方法来定位正确的实现类。
The advantage to storing the interfaces in a separate class library is that it actually decouples the implementing and using class libraries. If the interfaces are with the concrete implementing classes, then you have
ImplementingClasses.dll <--- ClientClasses.dll
If you put the interfaces into a separate assembly, it's more like this:
ImplementingClasses.dll ---> Interfaces.dll <--- ClientClasses.dll
Notice how this removes the coupling between your client code and the implementation - this will allow your total application to use a configuration-based approach to locating the proper implementing classes.