3 ms·
Where I work it is a hard convention. It is also a sensible convention because anything else makes the codebase even harder to navigate/refactor and whatever.
by bayesian_horse 5y ago
Where I work it is a hard convention. It is also a sensible convention because anything else makes the codebase even harder to navigate/refactor and whatever.
When working in teams, you really shouldn't put more than one class in one file, except for rare exceptions of very small and inconsequential classes. Otherwise the files get pretty big and the chance of merge conflicts get bigger.
The underlying problem - in my opinion - is that C# encourages you to overcomplicate things and that it is relatively verbose. Of course you can put a class with multiple members and methods in one line. But then it's also unreadable. Readability matters.
All languages with a syntax derived from C have a fundamental readability/verbosity problem, C# is no exception. F# for example doesn't have that baggage and is a lot more concise.