The tag has no wiki summary.

learn more… | top users | synonyms

0
votes
1answer
92 views

How can I avoid the “global $dbh” anti-pattern?

This is what most of my database-related library code looks like: lib.php <?php $dbh = new PDO(...); function doSomeDatabaseThing() { global $dbh; return $dbh->doStuff(); } function ...
1
vote
0answers
86 views

Python: Why are int & list function parameters differently treated? [migrated]

We all know the dogma that global variables are bad. As I began to learn python I read parameters passed to functions are treated as local variables inside the funktion. This seems to be at least half ...
3
votes
3answers
375 views

Separating Code into Smaller Files in C

I am in the process of cleaning up my code and making it easier to maintain. I am doing this by turning my 5000+ line file into separate smaller files. I have successfully created separate source and ...
3
votes
1answer
215 views

How to avoid global state without large function signatures?

So, there are some good answers to this question, namely: Why is Global State so Evil? I have a specific question about the alternatives Mikera proposed as the answer with the second most up-votes. ...
1
vote
1answer
72 views

Doesn't an event bus affect global state?

"Minimize mutable global state" is a more or less accepted program design principle. The reason often cited is that having global state can affect two components that don't are seemingly unrelated. In ...
3
votes
1answer
156 views

Where to keep global variables in Windows Forms App

I have here a Vb.Net employee management application. It has employees, managers, teams, trainings and so on. The way the application is set up now, data is read from the database in the startup form ...
1
vote
3answers
111 views

Setting global parameters: is this a reasonable use of const_cast and volatile?

I have a program that I run repeatedly with various parameter sets. Different parameters are used in different parts of the program (including different source files). The same parameter may also be ...
1
vote
1answer
567 views

Storing session in a static variable?

I'm currently checking a older piece of C# code used to maintain a login session. public static ZRWebserviceSession CurrentSession { get { return _currSession; } set { _currSession = value; } } ...
0
votes
1answer
1k views

Global variables in javascript

I don't consider myself a highly skilled javascript developer, but I thought I got one thing right for sure: don't create global variables unless you really have to. I've been learning angularjs ...
1
vote
2answers
95 views

Dependency injection for request variables in a web application

I'm working a PHP 5.5/MySQL web application. If a class depends partly on some global GET and POST variables for its members, should I just refer to them directly from within the class, or should I ...
0
votes
0answers
209 views

Use a global variable, a singleton, or something else

Preface: I am working in PHP (Abandon hope all ye who enter here). Background: There exists a large set of global functions in PHP, a number of which are miscellaneous system calls, like sleep (and ...
3
votes
2answers
168 views

messaging class and global state

This is a front end project that is using socket.io for all communication with the server. This allows for push which is good, but recently we have been asked to provide a pause button. The pause ...
1
vote
1answer
104 views

Is using a global to maintain the currently logged in user bad practice?

I'm doing some android development in a relatively inexperienced group, and all of the data used by our application is managed in a database. There are several instances where we'll need to pull info ...
1
vote
2answers
137 views

In Ruby, change global in thread safe block

In Ruby, I have a use case for a few common configuration options, e.g. NOOP, TRACE, SILENT. Right now I am using local vars instead of globals and passing them around all over the place and it's a ...
2
votes
2answers
164 views

Replacing static classes with global state to a series of POJOs, beginning to feel like an anti-pattern

I'm trying to refactor some code, and one of the major changes is to remove the (ab)use of static classes to give global state. I've tried to split up some of the 'global state' functionality with ...
2
votes
4answers
413 views

How to provide a ubiquitous object without including it in every parameter list

I'm writing a small C++ class, Block, to transform serialized data into a memory structure, and supply the structured data to callers through several accessor methods. I've tried to keep its scope ...
1
vote
1answer
384 views

Strategies for removing register_globals from a file

I have a file (or rather, a list of about 100 files) in my website's repository that is still requiring the use of register_globals and other nastiness (like custom error reporting, etc) because the ...