The variables tag has no wiki summary.
7
votes
3answers
51 views
Definition of “state”
What is a good way to define "state", as in state variable or state machine, to a new (previously non) programmer? What are some good ways to explain why this concept is useful for writing software? ...
2
votes
6answers
223 views
Should I refactor single letter variables for constructs like pointer/structure names?
And No, i am not referring to single variables in loops or exceptions. Lets say pointer/struct names in large c ,c++ programs . Are there any languages where this type of naming is acceptable or is ...
3
votes
1answer
117 views
Better use on the name of variables
I have a method that looks like this:
Public Function NormalizeStreetAddress(country As Namespace.Country,
streetAddress As Namespace.StreetAddress) _
...
4
votes
5answers
182 views
variable comparison without initialising
I am working with a project in VC++ which involves co-ordinate system having x,y,z axis.
I am trying to check for if a variable(Point with x,y,z values) is assigned on the coordinate system or its a ...
27
votes
15answers
2k views
Is it bad practice to name an unused variable with a single underscore?
Often when the syntax of the language requires me to name a variable that is never used, I'll name it _.
In my mind, this reduces clutter and lets me focus on the meaningful variables in the code. I ...
4
votes
3answers
101 views
Using “prevent execution of method” flags
First of all I want to point out my concern with some pseudocode (I think you'll understand better)
Assume you have a global debug flag, or class variable named "debug",
class a :
var debug = ...
3
votes
2answers
282 views
What is meant by Scope of a variable?
I think of the scope of a variable as -
"The scope of a particular variable is the range within a program's source code in which that variable is recognized by the compiler".
That statement is ...
2
votes
1answer
101 views
Giving variables default values vs. treating accessing an undefined variable as an error
Having messed around with several scripting languages and being a bit of a linguist, there seems to be a way to divide dynamically typed languages into two groups: languages that give variables a ...
4
votes
2answers
126 views
How to deal with variables when extracting methods in to smaller methods?
This is an abstract question to clarify a refactoring concept in the ruby language. Assume in the real world that there would be many more variables and method in the Furniture Class and Refinish ...
9
votes
8answers
506 views
Why do variables need a type?
So we write:
Customer c = new Customer();
Why is the design not such that we write:
c = new Customer();
c.CreditLimit = 1000;
The compiler can work out c points to a Customer and allow ...
23
votes
17answers
2k views
Is it a good practice to name the returned variable “result”? [closed]
Is it a good practice to call the variable a method returns with a variable name result?
For instance:
public Zorglub calculate() {
Zorglub result = [...]
[...]
return result;
}
Or ...
24
votes
9answers
2k views
Why should identifiers not begin with a number?
Most programming languages appear to be designed to not allow one to declare an identifier that starts with a number. I was just curious to know the reason. I have already searched the web, but ...
2
votes
5answers
294 views
Why is it discouraged to create variables on the fly? PHP gives you a Notice Error
Are you guys familiar with those pesky PHP notice errors? You know, the ones that will appear when you do something like this:
if($some_variable == 45)
But if $some_variable wasn't created already, ...
0
votes
2answers
143 views
Semantic or structure - which should get preference for variable naming?
We've a call stack in our project. The program is written for microcontroller, the language is C. The call stack is basically an array of integers. The variable that represents this call stack ends ...
11
votes
3answers
406 views
Handling extremely large numbers in a language which can't?
I'm trying to think about how I would go about doing calculations on extremely large numbers (to infinitum - intergers no floats) if the language construct is incapable of handling numbers larger than ...