Manual:Globals are evil/en

Globals are evil. The original MediaWiki code relied on globals for processing context far too often. MediaWiki development since then has been a story of slowly moving context out of global variables and into objects. Storing processing context in object member variables allows those objects to be reused in a much more flexible way. Consider the elegance of:

versus

Some of the current MediaWiki developers have an idle fantasy that some day, globals will be eliminated from MediaWiki entirely, replaced by an application object which would be passed to constructors. Whether that would be an efficient, convenient solution remains to be seen, but certainly PHP 5 makes such object-oriented programming models easier than they were in previous versions.

For the time being though, MediaWiki programmers will have to work in an environment with some global context.

For more information on the global variables used in MediaWiki, see.