将您的代表放在哪里。 。
我正在尝试确定我的应用程序的最佳目录结构
:
UI
数据
接口
,但我不知道在哪里放置委托。
是否应该有一个单独的委托文件夹,或者我应该将委托存储在使用它们的同一类中。 。
I am trying to determine the best directory structure of my application
i have:
UI
Data
Interfaces
but i dont know where to put delegates..
should there be a seperate Delegates folder or should i store the delegates in the same classes where they are being used . .
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您的委托有共同用途,则应该将它们存储在公共位置,但如果您仅在类中使用它,则将其放在同一个类中。
If you have an common use for your delegates, you should store them on a common place, but if you only use it in your class then put it in the same class.
您没有 Classes、Structs 和 Enums 文件夹。 为什么要有 Delegates 文件夹?
另外,如果您使用 C# 3.0,则通常应该使用通用委托 - System.Action 和 System.Func - 而不是命名委托。
You don't have a Classes, Structs, and Enums folder. Why have a Delegates folder?
Also, if you're using C# 3.0, you generally should be using Generic Delegates - System.Action and System.Func - instead of named delegates.
我认为这是一个坏主意。 您应该像 Microsoft 那样按功能对代码进行排序。
至于代表,你不再需要他们了。 现在我们已经有了通用的 Func 和 Action 委托,没有理由创建您自己的委托。
I think that's a bad idea. You should sort your code the same way Microsoft does, by functionality.
As for delegates, you don't need them any more. Now that we have the generic Func and Action delegates, there is no reason to create your own.
委托本质上是引用类型方法容器。 在我看来,您应该将委托存储在使用它们的同一类中。 无需创建单独的委托文件夹。
Delegates are essentially reference type method containers. In my opinion you should store the delegates in the same classes where they are being used. There is no need to create a separate delegate folder.