Naming conventions for java methods that return boolean(No question mark)

前端 未结 7 886
深忆病人
深忆病人 2020-12-02 10:49

I like using question mark at the end of method/function names in other languages. Java doesn\'t let me do this. As a workaround how else can I name boolean returning method

7条回答
  •  一向
    一向 (楼主)
    2020-12-02 11:45

    For methods which may fail, that is you specify boolean as return type, I would use the prefix try:

    if (tryCreateFreshSnapshot())
    {
      // ...
    }
    

    For all other cases use prefixes like is.. has.. was.. can.. allows.. ..

提交回复
热议问题