Having a larger WinForms application with several classes I currently pass references to several "central" objects around to function calls.
This leads to more method parameters.
Example:
public static class Program
{
private static MyCentral _central;
...
}
...
public class SomeController
{
public object SomeFunction(MyCentral central)
{
// Do something with the MyCentral instance.
}
}
Now I'm asking myself whether I should ditch this approach and instead use singletons for those central objects so that everyone can always access these objects and I do not need to pass them around anymore.
Example:
public static class Program
{
public static MyCentral Central { get; private set; }
...
}
...
public class SomeController
{
public object SomeFunction()
{
// Do something with the Program.Central singleton.
}
}
My question:
Are there any rules-of-thumb whether the singleton approach or the "passing objects around" approach should be prefered?