How to name a variable: numItems or itemCount?

前端 未结 5 451
暖寄归人
暖寄归人 2021-02-01 17:01

What is the right way to name a variable

int numItems;

vs.

int itemCount;

or constant:

public         


        
5条回答
  •  长发绾君心
    2021-02-01 17:45

    For Java I would use itemCount and MAX_ITEM_COUNT. For Ruby, item_count and MAX_ITEM_COUNT. I tend not to use names that can be interpreted wrongly (numItems may be a shortcut for numerate_items or number_of_items), hence my choice. Whatever you decide, use it constantly.

提交回复
热议问题