你应该在什么命名空间中放置相对于它们的实现者的接口? [英] In what namespace should you put interfaces relative to their implementors?

查看:157
本文介绍了你应该在什么命名空间中放置相对于它们的实现者的接口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

具体来说,当你创建一个接口/实现者对,并且没有重要的组织关注点(比如接口应该放在不同的程序集中,即按照s#体系结构的建议)你是否有一种默认的组织方式它们在你的命名空间/命名方案中?

Specifically, when you create an interface/implementor pair, and there is no overriding organizational concern (such as the interface should go in a different assembly ie, as recommended by the s# architecture) do you have a default way of organizing them in your namespace/naming scheme?

这显然是一个更基于意见的问题,但我认为有些人已经考虑过这个问题,我们都可以从他们的结论中受益。

This is obviously a more opinion based question but I think some people have thought about this more and we can all benefit from their conclusions.

推荐答案

答案取决于你的意图。


  • 如果您希望命名空间的使用者在具体实现上使用接口,我建议您将接口放在顶级命名空间中,并在子命名空间中使用实现

  • 如果消费者要同时使用它们,请将它们放在同一名称空间中。

  • 如果接口主要用于专门用途,比如创建新的实现,请考虑使用它们na子命名空间,如Design或ComponentModel。

我确定还有其他选项,但与大多数命名空间问题一样,它归结为项目的用例,以及它包含的类和接口。

I'm sure there are other options as well, but as with most namespace issues, it comes down to the use-cases of the project, and the classes and interfaces it contains.

这篇关于你应该在什么命名空间中放置相对于它们的实现者的接口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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