How to name a variable: numItems or itemCount?

前端 未结 5 446
暖寄归人
暖寄归人 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:27

    It's a matter of personal preference, just make sure you are consistent throughout your code. If you're working with others check what's been done in existing code.

    For the constant I would find MAX_ITEMS more logical than MAX_NUM_ITEMS or similar, it just sounds better to me.

提交回复
热议问题