# Words to separate value from counting

I'm a software developer, and as such I often come in contact with situations where I need to name variables related to the following context:

4 apples for \$3 each equals \$12

My problem is the word `amount` because it feels as natural to write `amount of items` (4) as `amount each` (\$3) or `total amount to pay` (\$12). But obviously I can't use the word `amount` for all of them and would like some guidance on what word to use in each situation.

English isn't my native language and I guess that's where my problem begins. What I basically would like to know, is:

• What is the best word to describe when you're counting items? My backup plan is `NoOfItems` but it's a bit complex with three words, I was hoping for a single word or something else more intuitive.
• What is the best word to describe when you're describing a value? I can't use `sum` because sometimes it's a single value that hasn't been summarised.

Thanks a lot...

-
Naming is explicitly off-topic, but you could use Count, Price and Total (and not use amount at all: as you indicate, it could be ambiguous). – Andrew Leach Oct 8 '13 at 14:26
I thought intuitive word separation of the different situations wouldn't be off-topic, since this is an English language forum. But I like your suggestions :) – Ohlin Oct 8 '13 at 14:36
In programming we use quantity/qty as var names for number of items – mplungjan Oct 8 '13 at 14:37
This is why it's off-topic. You could use Fred, Mary and Johnny and it would still be valid. Less understandable, but equally correct. – Andrew Leach Oct 8 '13 at 14:40
I do get your point there... – Ohlin Oct 8 '13 at 14:47

• "Quantity" = the countable number of a single item

• "Quantity per _" = the quantity that relates to a specific grouping

• "SubTotal" = just a handy in-between calculation

For your second question, I sound sarcastic saying this but the best word to describe a value is what the value actually is. :) From your example, you may be dealing with:

• "Price" or "Item Price"

• "Price per __"

• "SubTotal" would be very handy here as the amount representing "Quantity" * "Item Price". Then the "Total" variable can be reserved for the final total in an operation or loop that you're coding.

-
Thanks a lot for your suggestions...and you're right about the second question :) – Ohlin Oct 8 '13 at 14:49

I'm a developer as well, I try to make my variables easily understandable for the poor soul who comes after me and has to maintain my code. For number of a given set of things, I'll use thingCount. For the value of that or those things, I'll use thingValue and if there's a total amount of things, I'll use thingTotal. I don't worry about the verbosity of the variable names because it makes them more understandable and the compiler (at least in modern languages) doesn't care and they take up just as much space as terse variable names.

When I first started developing code (for AutoCAD of all things), I used to condense my variable names down to things like: tv which made perfect sense to me as long as I was actively working on the code, but let a couple of weeks go by, and tv again meant television instead of "thingValue", and I had to go back through my code to figure it out again. Much-much easier to simply name things after what they are regardless of verbosity because it's much-much easier to figure things out when you're deep down in the bowels of your code (or worse, someone else's that you have no history of). There's a good Uncle Bob (I think) quote & blog post on this that I'll try to find & update my answer with.

This isn't exactly the blog post I was looking for, but it's still a good start. I'll find the other one and get it in here as well.
Uncle Bob's Naming Conventions

Here's the original blog post, some of the humor may not ring true with folks like the OP who didn't grow up in the US, so apologies for that. However, the post is still very valid: