I have a static class Manager it should adapt between two tiers of logic would it be a bad practice
to devide functionalitlies by nesting static classes inside it?
I have about two dozen diffrent subjects to manage with 2 -3 functions each.
and would like to avoid creating 2 dozen classes for this
I mean use this:
static class Manager
{
static class Type1
{
static void Method1();
static void Method2();
static void Method3();
}
static class Type2
{
static void Method4();
static void Method5();
static void Method6();
}
static class Type3
{
static void Method7();
static void Method8();
static void Method9();
}
}
instead of:
static class Manager
{
static void Method1();
static void Method2();
static void Method3();
static void Method4();
static void Method5();
static void Method6();
static void Method7();
static void Method8();
static void Method9();
}
something like namespaces, but inside a class.
There are a number of options, if you are about design choices.
First, you can pour everything into a single class which would be terribly hard to debug and mixed several responsibilities.
Second, you can create nested classes, as you also noted, where you have better seperation of concerns / code but still have everything hardcoded and in one big source-code file.
Third, which is much more extendable, you can consider any container pattern you wish. I have listed one below which keeps your classes seperate and more easily testable should you care, as well as swappable.