问题描述
我需要一个好的变量名,当一个对象是列表中最后一个对象时返回false。
I need a good variable name for a boolean value that returns false when an object is the last in a list.
是'inFront',但我不认为这是描述性的。
The only decent name I can come up with is 'inFront', but I don't think that is descriptive enough.
另一个选择是isNotLast。这不是好的做法,虽然(代码完成,第269页,使用阳性布尔变量名称)。
Another choose would be 'isNotLast'. This is not good practice though (Code Complete, page 269, Use positive boolean variable names).
我知道我可以更改变量定义。因此,当一个对象是最后一个对象并调用变量'isLast'时返回true,但是,如果我有第一个解释,这将使这个任务更容易。
I am aware that I could change the variable definition. So true is returned when an object is the last and call the variable 'isLast', however, it would make this task easier if I had the first explanation.
推荐答案
isBeforeTheLastItem
isBeforeTheLastItem
isInFrontOfTheLastItem
isInFrontOfTheLastItem
isTowardsTheFrontOfTheList
isTowardsTheFrontOfTheList
也许太冗长,但他们可能会帮助你的想法。
Maybe too wordy but they may help give you ideas.
这篇关于命名约定:什么命名一个布尔变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!