Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.

Questions tagged [variables]

Variable or scalar is a storage location paired with an associated symbolic name (an identifier), which contains some known or unknown quantity or information referred to as a value.

Filter by
Sorted by
Tagged with
0 votes
3 answers
320 views

I'm wondering if it's bad practice to have a variable in a webserver which counts the amount of incoming requests and put it in an environment variable. In C# for example you have System.Configuration....
Vincent's user avatar
  • 383
0 votes
1 answer
168 views

If a lambda is frequently used, it is considered to reuse the same instance instead of creating new instances repeatedly. How can I minimize the number of captured variables in lambda expressions?
Arunabh's user avatar
1 vote
2 answers
322 views

I am trying to wrap my head around what the ECMAScript specification suggests about variable assignment. Introduction: Coming from Java, this is pretty straight forward. Variables get stored at a ...
tweekz's user avatar
  • 237
0 votes
2 answers
545 views

Coming from languages like C++, Java or PHP I've learned that there are Value Types and Reference Types. Value Types store values directly in the variable (in a box / memory location). Whereas ...
tweekz's user avatar
  • 237
0 votes
2 answers
755 views

From my understanding, a constant is a value which is assigned only once and cannot change at runtime, whereas variables have mutable values which are unpredictable by nature. My question is, to what ...
Clara's user avatar
  • 53
0 votes
2 answers
354 views

coders. I'm learning C programming language and found out such thing as #define directive that allows us to use symbolic constants (following Brain Kernigan). I know that this directives "insert&...
CoderDesu's user avatar
  • 1,015
10 votes
7 answers
2k views

I have a question regarding my general understanding of global state in software engineering. When I write an app I like to decompose it into little, manageable components and functions, that are ...
Angelica's user avatar
  • 109
1 vote
3 answers
254 views

for example: const arr = [1,2,3,4]; const coordinate = [arr[0] + 2, arr[0] + 1]; here arr[0] is written out twice, when the code is executed would it literally go and find same value twice or would ...
link2name's user avatar
32 votes
6 answers
8k views

Currently, I'm reading "Code Complete" by Steve McConnell, 24.3 chapter "Specific Refactorings". I've become kind of confused with 4th paragraph, that looks like: Move an ...
CoderDesu's user avatar
  • 1,015
16 votes
5 answers
9k views

The way I see used most frequently int main() { int i; for (i=0; i<10; i++) { printf("hello\n"); } return 0; } The way I’m used to int main() { ...
Nickotine's user avatar
  • 290
4 votes
2 answers
3k views

I've been reading a book about C#. What does the word 'set' mean in the following excerpt? Pattern matching with the switch statement: Like the if statement, the switch statement supports pattern ...
Hossein's user avatar
  • 75
2 votes
2 answers
3k views

I used docker to containerize the node.js express app and used GitHub action to add the .env file in the container. I googled this method when I was doing the DEV project. But I think that if someone ...
nermineslimane's user avatar
0 votes
1 answer
348 views

I tend to create a variable whenever I need an uncircumstantially same value as to that of an earlier value more than once (the values are not happening to be the same by chance rather they actually ...
Nae's user avatar
  • 197
1 vote
1 answer
140 views

Currently reading Steve McConnell "Code complete". "General issues in using variables" chapter, "Binding time" section. He says about variable's binding time in such ...
CoderDesu's user avatar
  • 1,015
-2 votes
3 answers
4k views

I want to select between "symbol(s)" and "character(s)" for my variables' names in cases when these terms are synonyms. Please teach me some information which allows to make this ...
Takesi Tokugawa YD's user avatar
3 votes
3 answers
2k views

A commonly repeated best practice is to not reuse local variables. However, when doing multiple small operations on the same variable, I struggle both with coming up with good names for all the ...
Godsmith's user avatar
  • 141
2 votes
5 answers
6k views

Computer Systems: a Programmer's Perspective says: 12.4.2 Mapping Variables to Memory Variables in threaded C programs are mapped to virtual memory according to their storage classes: Global ...
Tim's user avatar
  • 5,555
-2 votes
1 answer
170 views

Is using System Hungarian Notation for Android UI components (Views) valid? I mean using it ONLY for Views - no strSomething, boolStuff or similar names. For example, tvDescription (TextView), ...
Anxxy1's user avatar
  • 17
-3 votes
1 answer
228 views

I am writing an application where a single variable may be affected by different filters applied to the data that's read from the DB. Each different variation has to be stored (as each one serves ...
HumbertoWoody's user avatar
-2 votes
2 answers
134 views

I am trying to program a little game and for that I need to determine which's players turn. I am solving it firstly with a Nassi-Schneiderman diagram with a variable turn whic can be 1 or 2, but my ...
kripss's user avatar
  • 23
-1 votes
1 answer
453 views

Sorry if this is a silly question, but I am not a native english speaker and a lot of times it is difficult for me to come up with meaningful variable names. I have a table of users in our app. All ...
Karolis's user avatar
  • 115
2 votes
3 answers
150 views

Let's say we have two variables, eta and phi related by eta = cos(phi). Is there a way to link these variables in any programming language such that there's no need for two different functions, ...
BeeperTeeper's user avatar
2 votes
3 answers
4k views

We've started looking at functions, and our homework requires us to include some simple ones in our programming. As we've left it a little late in the semester to explore functions, we're well-used to ...
user316193's user avatar
-1 votes
2 answers
839 views

In Python variables that are created outside of a function are known as global variables. However to create a global variable inside a function (a local variable), you can use the global keyword. My ...
Qubit's user avatar
  • 197
37 votes
10 answers
15k views

Recently I've been trying to explain pointers in a visual way, as flashcards. Question 001: This is the drawing of a location in computer memory. Is it true that its address is 0x23452? Why? ...
progner's user avatar
  • 523
2 votes
3 answers
3k views

With 'global variables', I mean Variables on namespace level Static data members in classes Static variables in functions In a big C++ project I would like to have a mechanism (like a compiler option) ...
Borph's user avatar
  • 131
-5 votes
2 answers
268 views

// Default initialization int i; // i has an unspecified value return i; // Probably 0, but Unreliable i = 5; // i has a specified value i = int();// This will give it a specified value, 0 i = ...
Anon's user avatar
  • 3,649
-1 votes
1 answer
1k views

When writing unit tests, I want to reduce the cognitive load of the reader as much as possible. One thing I've noticed that bothers me is that the variable names of the thing that is being tested are ...
pascalwhoop's user avatar
5 votes
7 answers
2k views

I think this question can span multiple languages, but in C# specifically there is a clear distinction between a field (ex: private int a;) and a property (ex: private int b { get; set; }). While ...
Kyle Delaney's user avatar
0 votes
1 answer
124 views

There exist lots of discussions on variable naming. However, I would like to address a specific aspect. I am a data scientist and deal with dozens of features/variables/columns — however you may call ...
Xiphias's user avatar
  • 111
45 votes
5 answers
19k views

If I define a variable of a certain type (which, as far as I know, just allocates data for the content of the variable), how does it keep track of which type of variable it is?
Finn McClusky's user avatar
5 votes
3 answers
14k views

I try to use the best coding standards/practices, however in all of my googling and classes I have never learned which is proper form for declaring/defining variables like the examples below. I have ...
Paul Gildehaus's user avatar
2 votes
2 answers
451 views

Or simply asked WHY ? It simply does not seems logical ... if ( null.asInstanceOf[String] == null ) println ("null.asIstanceOf[String] is null") println ("BUT !!!") if ( null.asInstanceOf[...
Yordan Georgiev's user avatar
8 votes
3 answers
840 views

This might be a super nerdy, OCD-like, silly question, but... I love it when related variables have names of equal length, such that when written below one another, it lines up nicely. Eg: min/max: ...
Martijn Courteaux's user avatar
-1 votes
4 answers
936 views

I'm working with JavaScript and PHP right now. My JavaScript uses camelCase while my PHP uses under_score for variable/object/array naming. I often have JavaScript send data to PHP. In fact it's ...
Trevor's user avatar
  • 101
3 votes
3 answers
193 views

I have a written a function and intend to provide an input variable so that when it is true, user-information is printed to the console. If the variable is false the function is 'silent'. Console ...
gatorback's user avatar
  • 227
4 votes
2 answers
2k views

I'm developing an application with Python. I want to have a Boolean variable that represent whether something is buy or sell but I'm not sure how I should name it. Here are my current ideas: isBuy ...
tgwtdt's user avatar
  • 159
3 votes
2 answers
1k views

I've heard some developers say that if a variable is only referenced one place, to just replace the reference to it with the value assigned to it. I've also heard developers say if a function is only ...
jinglesthula's user avatar
6 votes
3 answers
7k views

Let's say I have the following function in Python: def foo(one, two): return one + two And I want to document it with "adds one to two". However, this is confusing, because I could just mean the ...
Pro Q's user avatar
  • 697
3 votes
1 answer
385 views

I'm writing a high level wrapper around the Python socket.socket object. Specifically, I want to do this for IPv4 TCP sockets (though it would be useful to be able to expand the library later with ...
Daniel's user avatar
  • 149
4 votes
1 answer
611 views

Under which circumstances would you deem it justifiable to use externs (i.e. global variables)? For example, in a system with 1 given state at a time, would it be appropriate to store this state in ...
Edward's user avatar
  • 51
43 votes
7 answers
10k views

I'm writing a program in Java where at one point I need to load a password for my keystore. Just for fun, I tried to keep my password in Java as short as possible by doing this: //Some code .... ...
Lord Farquaad's user avatar
2 votes
4 answers
2k views

I need few related variables (for example I have the lengths of 3 lines given. I have to say whether they form a triangle). Which variable naming convention is preferable in Java? len0, len1, len2 or ...
Md. Abu Nafee Ibna Zahid's user avatar
0 votes
4 answers
653 views

Is there a difference between defining a variable in C and assigning a value to a variable in C? I know that declaring a variable simply means telling the name and its type like int a. On the other ...
yoyo_fun's user avatar
  • 2,297
13 votes
3 answers
8k views

Say we set a variable in Python. five = 5 Boom. What I'm wondering is, how is this stored? Does the compiler or interpreter just put it in a variable like so? varname = ["five"] varval = [5] If ...
skistaddy's user avatar
  • 254
0 votes
2 answers
11k views

I've an entity class that the user will construct the object using the setters. This object when passed to another layer, that layer will call the constructChangeDataMap() method to identify the ...
Magesh Kumaar's user avatar
53 votes
15 answers
36k views

I read the first chapters of Clean Code by Robert C. Martin, and it seems to me it's pretty good, but I have a doubt, in one part it is mentioned that it is good (cognitively) that the functions ...
OiciTrap's user avatar
  • 729
32 votes
3 answers
15k views

At one point or another you might come over functions with a lot of arguments. Sometimes it makes sense to combine some of the arguments into super-arguments. I've often done this with dicts, but now ...
André Christoffer Andersen's user avatar
6 votes
2 answers
4k views

Up until now, I have been initializing most of my variables as such: const QString foo("bar"); Which from my newfound understanding, is known as direct initialization. (http://en.cppreference.com/w/...
Anon's user avatar
  • 3,649
1 vote
2 answers
603 views

I need to store two 32-bit numbers in a way that is quickly accessible and as storage space efficient as possible. My keys are a combination of the following two values: port: 0 - 29 vlan: 1 - 4095 ...
stdcerr's user avatar
  • 139

1
2 3 4 5