Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

让你最快速地改善代码质量的 20 条编程规范(中) #26

Open
NewBrandSTONE opened this issue Feb 17, 2020 · 0 comments
Open

Comments

@NewBrandSTONE
Copy link
Owner

  1. 类、函数多长最合适

    • 简单说不要超过一个屏幕的高度,一般50行左右。
  2. 一行代码多长最合适

    • 不要超过 IDE 显示的宽度。
  3. 善用空行分割单元块

    • 除了使用注释分割函数内的单元块,还可以使用空行分割。
    • 成员变量与函数之间、静态成员变量与普通成员变量之间、各函数之间,都可以使用添加空行的方式,让这些不模块的代码之间,界限更加明确。
  4. 类成员的排列顺序

    • 在类中,成员变量排在函数前面。
    • 成员变量之间或函数之间,都是按照 “先敬爱(静态函数或静态成员变量)、后普通(非静态函数或非静态成员变量)”的方式来排列的。
    • 先写 public 成员变量或函数,然后是 protected ,最后是 private 的。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant