3 ms·
Do you understand that this is a choice made by someone instead of a requirement?
by metaltyphoon 5y ago
Do you understand that this is a choice made by someone instead of a requirement?
- mtone 5y agoIt's not just idiomatic but pretty much standard in C# to have a single file per class so it's a fair criticism.
- metaltyphoon 5y agoNo it's not "idiomatic". Stop this nonsense. Look at the biggest C# code base, ASP.NET Core, and there are many instances where this is not the case. You don't need to preface a method with `private` to be so but people still do it, why? My theory is the influx of Java dev influences, same with the "One class per file nonsense".
- bayesian_horse 5y agoWhere 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.
- bayesian_horse 5y agoIt is a convention, but not entirely without reason. Breaking the convention leads to other problems. You still need a metric shit ton of classes, so finding any one class gets harder. The chance of merge conflicts increases because of more lines per file.