-
개수를 뜻하는 변수는 어떻게 지어야할까? count? number?개발 흉내 2021. 3. 31. 11:04
객체가 있고 그 객체를 세어서 저장해야할 때가 있다.
보통
countOfItem
을 많이 사용했는데 오늘 JPA의 응답을 보니numberOfElements
라는 속성이 보여서 당황스러웠다.cntOfItem
이나numOfItem
같은 보편적인 줄임말도 지양하라는 글을 어디선가 봤는데 또 다른 고민이 생겼다.개수를 표현하는 말로써 count와 number 중에 어떤게 더 타당할까?
https://stackoverflow.com/questions/6358588/how-to-name-a-variable-numitems-or-itemcount
How to name a variable: numItems or itemCount?
What is the right way to name a variable int numItems; vs. int itemCount; or constant: public static final int MAX_NUM_ITEMS = 64; vs. public static final int MAX_ITEM_COUNT = 64;
stackoverflow.com
유명한 저자 스티브 맥코넬의 "Code Complete"에 의하면 Number는 모호한 표현이라고 한다.
개수는 count로 표현하고 특정한 요소는 index로 표현해야한다고 말한다.
결론적으로
itemCount
또는item_count
로 표기하는 것이 가장 타당해보인다.