Program.cs
Program.cs
Foo/Bar.cs
Foo/Bar.cs
Foo/Baz.cs
Foo/Baz.cs
Flob/Wibble.cs
Flob/Wibble.cs
Flob/Wobble.cs
Flob/Wobble.cs
Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Visit Stack ExchangeStack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
Explore Stack InternalProgram.cs
Foo/Bar.cs
Foo/Baz.cs
Flob/Wibble.cs
Flob/Wobble.cs
Program.cs
Foo/Bar.cs
Foo/Baz.cs
Flob/Wibble.cs
Flob/Wobble.cs
Just embrace the convention that static classes are used like namespaces in situations like this in C#. Namespaces get good names, so should these classes. The using static feature of C# 6 makes life a little easier, too.
Smelly class names like Helpers signal that the methods should be split up into better-named static classes, if at all possible, but one of your emphasized assumptions is that the methods you're dealing with are "pairwise unrelated", which implies splitting down to one new static class per existing method. That's probably fine, if
As a contrived example, Helpers.LoadImage might become something like FileSystemInteractions.LoadImage.
Still, you could end up with static class method-bags. Some ways this can happen:
It's important to remember that these static class method-bags are not terribly uncommon in real C# codebases. It's probably not pathological to have a few small ones.
If you really see an advantage in having each "free function"-like method in its own file (which is fine and worthwhile if you honestly judge that it actually benefits your project's maintainability), you could consider making such a static class instead a static partial class, employing the static class name similar to how you would a namespace and then consuming it via using static. For example:
namespace ConsoleApp1 { using static Foo; using static Flob; class Program { static void Main(string[] args) { Bar(); Baz(); Wibble(); Wobble(); } } } namespace ConsoleApp1 { static partial class Foo { public static void Bar() { } } } namespace ConsoleApp1 { static partial class Foo { public static void Baz() { } } } namespace ConsoleApp1 { static partial class Flob { public static void Wibble() { } } } namespace ConsoleApp1 { static partial class Flob { public static void Wobble() { } } }