Is it a bad practice to have multiple classes in the same file?

后端 未结 15 2213
眼角桃花
眼角桃花 2020-12-08 03:48

I used to have one class for one file. For example car.cs has the class car. But as I program more classes, I would like to add them to the same file. For

15条回答
  •  感情败类
    2020-12-08 04:31

    I've found that whenever I try to combine multiple types into a single file, I always end going back and separating them simply because it makes them easier to find. Whenever I combine, there is always ultimately a moment where I'm trying to figure out wtf I defined type x.

    So now, my personal rule is that each individual type (except maybe for child classes, by which a mean a class inside a class, not an inherited class) gets its own file.

提交回复
热议问题