Considering that I keep seeing it, I feel the need to point it out and make a note: This is not OOP. This is a convoluted function call. The names have been changed to protect the guilty.
$newObject = MyObject::createObject(array(
"someStuff" => $datas,
"morestuff" => $moreDatas,
"typo" => $lolTypes,
"theKitchenSink" => KitchenSinkFactory::getInstance()
));
$newObject->doStuff();
$results = $newObject->getResults();
If that is the entirety of the API that one is expected to use from MyObject, then, really, it's just a function call pretending to be an object.
That pattern would be useful if the object in question went off and did something asynchronously, so you could ask it to start and then come back later for the answer.
ReplyDeleteOf course, that's obviously not what's going to happen in PHP!
@ghewgill: Hah. I've been in PHPland so long that thought didn't even occur to me. But those lines appear one after another in my script, so even if PHP supported threading/asynchronous calls, that's not what that pattern is being used for.
ReplyDeleteAnd by "my script" I mean "the script that I am contemplating updating", not "the script that I wrote". :p
ReplyDelete