How to organise large code files?

后端 未结 7 978
失恋的感觉
失恋的感觉 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 09:58

    Separate your code into responsibilities. For each responsibility, define a single type. That is, follow the Single Responsibility Principal. Doing so will result in smaller units of code, each of which performs a very specific function. Not only does this result in smaller files, but also in better design and maintainability.

提交回复
热议问题