码迷,mamicode.com
首页 > 其他好文 > 详细

项目管理 - Coding Standard

时间:2021-01-28 12:20:52      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:测试   ica   hand   thrown   param   代码结构   form   strong   sse   

Code Structure 代码结构

命名保持规范,驼峰命名。

Boolean方法,起名要以"is" / "has"开头。

方法名称要是动词。

 

......

Design Principles 设计原则

Apply the Single-Responsibility principle to increase cohesion

Apply the Open-Closed principle for extensible design

 

......

 

Structural Complexity 结构复杂度

Cyclomatic Complexity should not exceed 10

  • Methods should not be too complex
  • Classes should not have too many methods

Depth of Inheritance Tree should not exceed 5

Lines of code per function should not exceed 100

Parameters per function should not exceed 7

 

 

Error Handling 错误处理

Throwable.printStackTrace(...) should not be called

Exceptions should not be thrown in finally blocks

Don‘t swallow exceptions without commenting why

....

 

Logging 日志

Do not log Sensitive / Confidential data (such as passwords)

Log all authentication success and failures

 

 

Unit Testing 测试用例

Write unit tests for all new code/projects, and for all bug fixes (including legacy code)

Each function should have unit tests that cover normal conditions, edge conditions and error handling

Use Mock objects in Unit Tests

 

Information Security  信息安全

Use strong authentification process

All forms of user input should be validated and sanitized

 

项目管理 - Coding Standard

标签:测试   ica   hand   thrown   param   代码结构   form   strong   sse   

原文地址:https://www.cnblogs.com/frankcui/p/14337763.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!