Code Style Guidelines for Contributors Reading Notes

本文提供了一套详细的Java编程规范,包括异常处理、代码结构、命名约定等,旨在提高代码的可读性和维护性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Reading Notes:
1、You must handle every Exception in your code in some principled way.
(if you are confident that actually ignoring the exception is appropriate then you may ignore it, but you must also comment why with a good reason)
2、Don't Catch Generic Exception.
3、we don't use finalizers.(there are no guarantees as to when a finalizer will be called, or even that it will be called at all.)
4、import foo.Bar;
(Makes it obvious what classes are actually used. Makes code more readable for maintainers.)
5、When creating new components never use deprecated libraries.
6、Every class and nontrivial public method you write must contain a Javadoc comment with at least one sentence describing what the class or method does.
7、Write Short Methods
If a method exceeds 40 lines or so, think about whether it can be broken up without harming the structure of the program.
8、Fields should be defined either at the top of the file.
9、The scope of local variables should be kept to a minimum
10、Loop variables should be declared in the for statement itself unless there is a compelling reason to do otherwise
11、We use 8 space indents for line wraps
12、Non-public, non-static field names start with m.Static field names start with s.Other fields start with a lower case letter.Public static final fields (constants) are ALL_CAPS_WITH_UNDERSCORES.
13、Braces do not go on their own line
14、Each line of text in your code should be at most 100 characters long.
15、Use Standard Java Annotations
16、Use TODO comments for code that is temporary, a short-term solution, or good-enough but not perfect.
17、Log Sparingly
18、Follow Test Method Naming Conventions(testMethod_specificCase1、testIsDistinguishable_protanopia)

 

thanks

jack.lee

转载于:https://www.cnblogs.com/jackxlee/p/CodeStyleGuidelines.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值