How to organise large code files?

后端 未结 7 990
失恋的感觉
失恋的感觉 2021-02-06 09:27

I am increasingly aware that my code in any single file can often span hundreds of lines quite easily and although I know the implementation might be sound, it still feels messy

7条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-06 10:11

    I tend to group properties, constructors, methods, and helper methods (private methods) together with regions. If I have a lot of methods, I create more regions based on what they do (especially good for overloads). And speaking of overloads, try minimizing your code with optional parameters.

    As far as I understand partial means that the class exists in two separate files. Webforms and controls are partial because the other "part" of the file is the as[p|c]x file that goes with it.

提交回复
热议问题