Studies on optimal code width?

前端 未结 11 667
滥情空心
滥情空心 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:09

    I normally use 120-150 unless the company describes otherwise. However it depends also on the kind of code:

    • I (almost) never use multiple statements on one line
    • I only use long lines (>12) only if lines that look similar can be aligned and not broken.
    • I always use enough spaces/parenthesis etc
    • I prefer longer variables names above shorter names

    Until a few years ago I limited to 100 but now widescreens are normally used and high resolution monitors 120 can be even seen on laptops (which I barely use).

    Comparing a screen to a book is not really good because a book has more vertical space and a screen has more horizontal space. I always try to keep a function max. one visible screen long.

提交回复
热议问题