On 9/11/07, Tim Starling tstarling@wikimedia.org wrote:
Methods don't exist in a vacuum, they exist to support certain public user interface operations, such as:
- Page view
- Edit
- Upload
- RC
- Watchlist
- Login
And:
* Anything else anyone thinks of at some point in the future
Flexibility isn't important if you consider a fixed set of operations, obviously.
If I may turn the question around, what do you envisage to be the applications for, say, the $user parameter to ParserOptions::__construct()?
Well, first I'll give you a nice concrete example where I was bitten by this trying to write an extension for another piece of software. I wanted to write a plugin for vBulletin that would read through each post made, and if it contained a word on a blacklist, report it to the moderators. One of the problems I encountered was that the existing code for reporting posts relied on globals, and assumed that the only person who could possibly be reporting posts would be the global user. But here, I didn't want the person to show up as reporting their own post, I had a pseudo-account set up for the purpose. If I had a function like report( $reporter, $postid, $reason ), it would have been entirely simple. As it is, I never got the plugin to work to this day.
For ParserOptions, of course, you might want to render the page according to some different set of options than the global user has. Not terribly likely, but then that's not the best example.
On 9/11/07, Thomas Dalton thomas.dalton@gmail.com wrote:
I don't see what is to be gained by bundling them together, either, it just replaces lots of small globals with one big one - surely that's just a waste of resources?
If they're no longer globals, they need to be bundled together into a single variable for the most part. Otherwise you'll have to constantly update various methods' call lines when you realize you now want to refer to some property of the user in some method or other that wasn't previously passed a user object. Globals do simplify call lines, because they're implicitly passed to everything, as it were.