Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Global variables joke [closed]

What’s the best naming prefix for a global variable?

//

I saw this joke on the wall in my CS lab and, being fairly inexperienced in C++, didn't get it.

Could someone explain it to me?

like image 604
Mutantoe Avatar asked Jul 15 '15 09:07

Mutantoe


People also ask

Why are global variables a bad practice?

Using global variables causes very tight coupling of code. Using global variables causes namespace pollution. This may lead to unnecessarily reassigning a global value. Testing in programs using global variables can be a huge pain as it is difficult to decouple them when testing.

When to use global variables in c++?

Global variables should only be used when you have no alternative. And yes, that includes Singletons. 90% of the time, global variables are introduced to save the cost of passing around a parameter.

Should you use global constants?

Although you should try to avoid the use of global variables, it is generally permissible to use global constants in a program. A global constant is a named constant that is available to every function in a program.

Is it OK to use global variables in JavaScript?

Avoid globals. Global variables and function names are an incredibly bad idea. The reason is that every JavaScript file included in the page runs in the same scope.


1 Answers

// means that the rest of the line is a comment. Global variables are generally seen as poor design, so the joke is that the best thing to do with global variables is to get rid of them.

like image 131
TartanLlama Avatar answered Sep 25 '22 23:09

TartanLlama