Questions tagged [scope]
The scope tag has no summary.
77 questions
-1
votes
3
answers
247
views
How to propagate lexical scope in a compiler, specifically around step-by-step functions?
I am working on a compiler in TypeScript, and currently am focused on how to pass around the "lexical scope" to the relevant objects. Essentially every time there is a conceptual major ...
1
vote
2
answers
244
views
Strategies to abstract away technical details when dealing with transactions
I like programming in such a way that every component/injectable of the applications I build, has a clearly defined scope, and it's easily tested.
With years working as a Developer I've come to ensure ...
0
votes
0
answers
91
views
Lambdas vs scope blocks for encapsulation in c++
When working with functions that run a few short "procedures" in sequence that are not used anywhere else and it makes sense to keep it all inline, in a single function, a large part of the ...
10
votes
7
answers
2k
views
Is global state really always bad?
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 ...
0
votes
2
answers
62
views
Should an Express error handler be used to send HTTP 4xx responses?
In other words, should the raising of an HTTP 4xx code be considered an error, and should the job of sending an HTTP 4xx code to a client be delegated to an error handler?
Or is it simpler to just ...
3
votes
3
answers
4k
views
Define "constants" at the global or function scope?
I often define variables that will never change, i.e. constants, at the top of a script/module. But recently I've been wondering if it makes sense to define them at the function scope level if they ...
0
votes
1
answer
66
views
When should javascript files be loaded
I am using a great deal of jquery.
I have several "sub-pages" that are loaded into a main div by a menu click. Each of those sub pages has an associated javascript file.
I have been loading the ...
1
vote
2
answers
110
views
An 'internal' scope class available only to selected classes
In many languages there is a scope that is just less than public called internal.
Wondering, Why none of the language, implemented a feature on internal such that one can specify
Only what other ...
9
votes
2
answers
4k
views
Is `this` in JavaScript an example of dynamic scoping?
Variables in JavaScript are lexically scoped. But, I wonder, is the this keyword, referring to the receiver of a method, an example of dynamic scoping. Or is this unrelated to the lexical/dynamic ...
-1
votes
1
answer
214
views
if (a) {b();c();d();} else {c();} - prevent duplicate code c(); [duplicate]
I've got the following scenario:
bool bWantToWait = getRandomBool();
if (bWantToWait){
std::future<bool> bSuccesfullWait = this->doStartWait();
}
//lots of lines of code
//even more ...
2
votes
3
answers
98
views
Should product scopes and/or project scopes be considered for small internal development work
tl;dr: I work at a small company with a development team of 5-10 people, lately we have been asked to present "scope documents" for effectively all of our work before we carry out the actual work, ...
37
votes
8
answers
10k
views
Does "variables should live in the smallest scope as possible" include the case "variables should not exist if possible"?
According to the accepted answer on "Rationale to prefer local variables over instance variables?", variables should live in the smallest scope possible.
Simplify the problem into my interpretation, ...
1
vote
1
answer
74
views
Should I group all sound file definitions together? Or define some of them locally, if possible?
For example, suppose my application have some sound files, now I define all sound file references in a single class:
public class SoundHelper{
public static Sound buttonSound=new Sound("(some url)...
8
votes
7
answers
1k
views
Why is scope a good thing? [duplicate]
I'm a newbie coder. I find it troublesome to declare a variable in 1 function and not be able to access it in other functions. I have to make many of my variables global just to get my code to work. ...
0
votes
2
answers
272
views
Exponential Growth of Scope of C++ Projects
I've been coding in C++ professionally for six odd years, and it's my go-to language for performance-critical projects. When working to a deadline, the scope expands to fill the time available. ...