布尔方法命名可读性 [英] Boolean method naming readability
本文介绍了布尔方法命名可读性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
简单的问题,从可读性的角度来看,您更喜欢布尔方法的哪个方法名称:
Simple question, from a readability standpoint, which method name do you prefer for a boolean method:
public boolean isUserExist(...)
或:
public boolean doesUserExist(...)
或:
public boolean userExists(...)
推荐答案
public boolean userExists(...)
会是我的首选.因为它使您的条件检查更像自然英语:
Would be my prefered. As it makes your conditional checks far more like natural english:
if userExists ...
但我想没有硬性规定——只要保持一致
But I guess there is no hard and fast rule - just be consistent
这篇关于布尔方法命名可读性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文