What is the best among GetCountOfObjects, GetNumberOfObjects and GetObjectCount?

I am a C ++ programmer from a non-English country. I am always confused about how to choose one of the following function names:

GetCountOfObjects

GetNumberOfObjects

GetObjectCount

Who can tell me what are the subtle differences between them?

+3
source share
5 answers

GetNumberOfObjects probably seems the closest to natural English. GetCountOfObjects sounds a bit uncomfortable. In addition, there is almost no difference.

My personal style will probably be using GetNumberOfObjects for a method that just returns a known number, but CountObjects for a method that actually does the counting.

EDIT: , , , "" , "count" .

, . , , .

+3

, , -

  • ,
  • , .
  • , , , "Of".

, IMHO "GetObjectCount" , , .

+4

, , .

+3

: size(), . , - , - , , , .

, Java getter seters , ++ get : GetNumberOfObjects = > NumberOfObjects, GetObjectCount = > ObjectCount... (, , size()), , , ObjectCount numObjects. numObjects , , .

0

Use the one that suits you, but be consistent. These are very long names, as you may be mistaken. In addition, you can use the general form of the name difference d. 2 help u determine the type of a variable or static, local or public or private

-9
source

Source: https://habr.com/ru/post/1779353/


All Articles