views:

170

answers:

4

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 . .

+6  A: 

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.

JSC
A: 

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.

Pradeep Kumar Mishra
+1  A: 

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.

David B
Really? I don't mean this to be argumentative, but that is the first time I have read that recommendation. Can you point me to sources on that recommendation so I can learn more?
flipdoubt
Sure, look for "simplifies this code by" at this link: http://msdn.microsoft.com/en-us/library/bb549151.aspx
David B
+1  A: 

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.

Jonathan Allen