What is the proper way to format code?

前端 未结 22 2144
没有蜡笔的小新
没有蜡笔的小新 2021-02-18 18:33

When I write code, I try to group lines of similar code together, then leave a blank line and write another block.

I believe this contributes to the neatness and readabi

22条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-18 18:57

    Spaces help to make your code more readable and I think the consensus here is that they are not for the most part a bad idea. But nobody seems to have pointed out that along with the blank line a comment may not be amiss.

    /* This section preps the widgets for display */
    block 
    of some 
    code
    
    /* This section passes the widgets to the display handler */
    and 
    so 
    on
    

    Remember most code will be read many times over it’s life so anything you can do to make life easier for future maintainers is a great plus.

提交回复
热议问题