美文网首页
2018-12-04Boolean method XX is a

2018-12-04Boolean method XX is a

作者: 俊德 | 来源:发表于2018-12-04 14:56 被阅读0次

In Clean Code, Robert Martin writes, “Negatives are just a bit harder to understand than positives. So, when possible, conditionals should be expressed as positives.” (Martin, [G29]). IntelliJ IDEA has three inspections to help you stay positive.

在洁净代码中马丁.罗伯特写到:负值比正值难以理解一点。因此,如果可能,尽量使用正值的表达式。IntelliJ IDEA有三项检查帮助你保留正值。

for example:

boolean isBigger(a,b){

return a >b;

}

boolean isLess(a,b){

return a <=b;

}

if(!isBigger(c,d)){//1

System.out.println(c+"is less than " +d);

 }

if(isLess(c,d)){//2

   System.out.println(c+"is less than " +d);

 }

2 是比较好理解的代码,1是比较难以理解的代码。

相关文章

网友评论

      本文标题:2018-12-04Boolean method XX is a

      本文链接:https://www.haomeiwen.com/subject/gnwmcqtx.html