Avoid global state
See original GitHub issueAs for me, having global state like this:
import "./SomeController" // import result affects as a global variable
let app = createExpressServer() // express server implicitly use "SomeController"
is not a good idea, because is handles like global variables. For example, this requries to clear metadata storage before each functional test. I think it could be better, if you made this opt-in, and add ability to explicit pass controllers, interceptors and other citizens to createExpressServer:
import SomeController from "./SomeController"
import SomeInterceptor from "./SomeInterceptor"
let app = createExpressServer(
SomeController,
SomeInterceptor
)
or somehow else. What do you think about it?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:7 (6 by maintainers)
Top Results From Across the Web
Why is Global State so Evil?
Mutable global state is evil because it's very hard for our brain to take into account more than a few parameters at a...
Read more >Global Variables and States: Why So Much Hate?
The simplest way to avoid globals all together is to simply pass your variables using function arguments. Let's take a simple example: <?php ......
Read more >How to Overcome Your Fear of Bad Global State - MethodPoet
Global state is generally considered bad in programming for a variety of reasons. Let's explore some of the reasons and look at the...
Read more >Avoiding mutable global state in browser JS | by Josh Wulf
This means that a local function cannot set the global state by passing in an array of members, and then mutate the global...
Read more >How do you guys manage "global" state? : r/cpp
I like to avoid global's and just pass stuff in as much as possible. I think singletons are kind of an anti-pattern.... certainly...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Global state for decorators can be avoided, if metadata information will be stored inside class function (for example in
$metadataor$reflection) property. Thank you for that points, I’ll check that.This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.