1

I am a software engineer and I struggle with the variable names, regarding this scope, what would be the best suited term for a counter.

For example if I want to count parts, would "Parts Counted" a better name than "Number Of Parts", thanks in advance, any advice would be very appreciated.

Edit

The suggestion from Juan José Melero Gómez is very interesting, i will put it here in order to use it as added in info:

in order to refer to a certain quantity of elements, in natural language we use "number of elements", "amount of elements" or "quantity of elements". However, in the IT field, where variable names need to be really shortened concatenated versions of the natural language, what would be a "correct" way to shorten these expressions? "elementCount" is something we see often, but as non-native speakers, we cannot tell if it's "correct" or whether we may prefer to use "elementAmount" or "elementQuantity" instead because of nuances

9
  • 2
    “Parts counted” suggests that the process of counting is incomplete; not that further parts are expected and will be counted on arrival, but that they’re already on hand and simply not yet counted. Entirely idiomatic in software written by native English speakers are PartsCount (where count is understood as a noun) and NumParts (the use of CamelCase here is of course subject to the conventions of the programming language being used and the house style wherever the coding is being done.) Aug 31, 2023 at 14:26
  • 1
    [correction: the best suited term]
    – Lambie
    Aug 31, 2023 at 16:42
  • 1
    I’m voting to close this question because it's about selecting a good name for part of a computer program and not about learning English. (The answer would likely be opinion-based, anyway, making it off-topic.) This question would probably be better suited for SO or some other programming site. Sep 1, 2023 at 3:25
  • 1
    This is not off-topic, it's about word choice. Let me rephrase: in order to refer to a certain quantity of elements, in natural language we use "number of elements", "amount of elements" or "quantity of elements". However, in the IT field, where variable names need to be really shortened concatenated versions of the natural language, what would be a "correct" way to shorten these expressions? "elementCount" is something we see often, but as non-native speakers, we cannot tell if it's "correct" or whether we may prefer to use "elementAmount" or "elementQuantity" instead because of nuances. Sep 11, 2023 at 9:38
  • 1
    I'm a programmer myself and I've wondered about this uncountable times. Sep 11, 2023 at 9:39

2 Answers 2

2

"Number of parts" implies that this is the number of parts that actually exist.

"Parts counted" is just the number we have been able to count, implying we don't know how many there really are in total.

Use the first if you know for sure that you have identified all the parts.

I am a programmer myself, so understand the confusion as "count" is generally used in code to mean the actual number that exists (e.g. length of a list). This is not the common Englisg usage though.

1

Both "Parts Counted" and "Number Of Parts" are (or at least can be depending on application) accurate. In most code I see, number of parts (or numParts or num_parts, etc.) is used most frequently for counters.

However, if you wanted to be very clear and explicit, you might choose parts counted for a counter because it implies "parts counted so far" whereas number of parts when used for a counter implies "number of parts counted so far." You're assuming/implying less.

You might decide to use number of parts when you assign a static integer value to a variable and this does not get updated (e.g., after a count, or if the value is already known). You might decide to use parts counted when the variable is in use while it is changing. For example, you are keeping track of how many times you've counted an iteration of a loop and using it to decide some action or termination condition within the loop.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .