answersLogoWhite

0


Best Answer

No. Variable names are best kept as short as possible so long as they remain self-explanatory. The name "cost" alone implies an amount of some kind (usually currency but not always).

Also, if a name consists of more than one word, an underscore makes it more readable. E.g., "cost_amount" would be better than "costAmount", but "cost" alone would still be better.

It's also a good idea to put variable names in namespaces unless they are local variables or class members. That way you're less likely to end up with name-clashes in the global namespace.

User Avatar

Wiki User

9y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Is costAmount a good idea for a variable name?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What makes for a good or bad variable name in C plus plus programming languages?

A good variable name is one that is clear, related to the data it stores. Also, you should try to avoid confusions with other variables.


What is Variable Shadowing in Java?

In Java, there are three kinds of variables: local variables, instance variables, and class variables. Variables have their scopes. Different kinds of variables have different scopes. A variable is shadowed if there is another variable with the same name that is closer in scope. In other words, referring to the variable by name will use the one closest in scope, the one in the outer scope is shadowed.A Local Variable Shadows An Instance VariableInside a class method, when a local variable have the same name as one of the instance variable, the local variable shadows the instance variable inside the method block.


What is variable initialization in computer programming?

Well, in languages like C or C++, a variable is just a memory cell. The memory cell can contain any, and then I really mean any, value. For instance, if I were to do something like the following:int x;Then I would have no idea what the value of x is, since I did not initialize it. However,int x = 0;initializes the variable to be zero.


Is a global variable a non-local variable?

True, a variable cannot be both global and local. But if a global and a local variable share the same name, the local one will hide the global.


How do you access global variable from within the main function when the local variable is of the same name?

When you acess a global variable inside main function you must use the same name, because the variable declared as global can be accessed by any function/procedure on the class where it was defined.