Follow

Junior dev: What's the best prefix for global variables?

Senior dev: //

@fribbledom Reminds me of a "senior" engineer at a previous employer who used a static variable to store state in a web application. Unsurprisingly, I left a month after that gem.

@viv @fribbledom
There once was a master programmer who wrote unstructured programs. A novice programmer, seeking to imitate him, also began to write unstructured programs. When the novice asked the master to evaluate his progress, the master criticized him for writing unstructured programs, saying, ``What is appropriate for the master is not appropriate for the novice. You must understand the Tao before transcending structure.''

@viv @fribbledom
IOW, the static variable may've actually been good in this particular case for some arcane reasons.
But in year 2021, I'd expect the arcane reasons to be explained in an angry 21-line comment above the static variable.

@fribbledom Obviously you put it in a singleton, and just inject that singleton through Inversion of Control so the global state is no longer in global variables and it isn't a problem.

...that was painful to type...

@fribbledom As an anarchist and a functional programmer, I oppose both kinds of global state.

@fribbledom if it ain’t broke, don’t fix it.

If it solves the problem and doesn’t introduce an overage of foreseeable debt, don’t knock it till you try it.

If you you’re worried about undefined behavior, then define the behavior you’re worried about.

Sign in to participate in the conversation
Mastodon

Server run by the main developers of the project 🐘 It is not focused on any particular niche interest - everyone is welcome as long as you follow our code of conduct!