Studies on optimal code width?

前端 未结 11 656
滥情空心
滥情空心 2021-01-29 18:42

If you enable the \"View Right Margin\" in your IDE of choice, it is likely that it will default to 80 characters. I tend to change it to 120 for no reason other than it was th

11条回答
  •  迷失自我
    2021-01-29 19:00

    Have mercy on the programmers who have to maintain your software later and stick to a limit of 80 characters.

    Reasons to prefer 80:

    • Readable with a larger font on laptops

    • Leaves space for putting two versions side by side for comparison

    • Leaves space for navigation views in the IDE

    • Prints without arbitrarily breaking lines (also applies to email, web pages, ...)

    • Limits the complexity in one line

    • Limits indentation which in turn limits complexity of methods / functions

    Yes, it should be part of the coding standard.

提交回复
热议问题