sooqua sooqua - 4 months ago 19
C# Question

Is it a bad practice to have each method in a separate file?

I made a

static partial class Utils
and I put each method in a separate file in the Utils folder.

But then looked up the partial classes and everywhere it says I shouldn't be using it except for separating auto-generated code.

So, should I merge it together or it's ok to have it in one folder?


First of all a Utils class with many methods tends to become a huge pile of much unrelated code. Because nearly all "Helper" methods will be placed there. By dividing them into single files you fight against a symptom and not againt the root cause. You'll transform the pile of code into a pile of files.

You should cluster the methods into topics and divide the Utils class in meaningful units. Please keep an eye on the Single Responsibility Principle.