In the title, with namespace-related elements, I refer to Enums
, Delegates
and other elements that do not belong to a single class, but to the whole namespace, or application.
I know that I can cram these into the namespace just about anywhere, for example, if I use WPF, I usually put them into App.xaml.cs, so that I always know where to find all of them:
namespace MyNameSpace
{
enum MyEnum
{
element1, element2
};
public delegate void MyDelegate();
public partial class App : Application
{
/*some App-wide code here*/
}
}
I would like to know, however, if there is a generally accepted way of doing this that developers are expected to know about and use like in the form of a Design Pattern or Best Practises, so that I can get used to this early on. I would also be glad to read about not exactly general, but practical ways with (brief) explanation (e.g., uses less resources than another way, or it is easier to UnitTest
it etc.) as to why is that particular way of arranging these items is good.