2006/10/5, John Wells <wellsdjohn@xxxxxxxxx>:
On 10/5/06, Martin Alterisio <malterisio777@xxxxxxxxx> wrote: > PHP seems to be getting more and more object oriented, I think it's the > right time to start questioning what have been done so far in terms of OOP > in PHP, because, honestly, there are too many php classes being distributed > out there that are a complete mess. Forget about spaghethi code, we have to > deal with pizza classes too. [code] require_once('previousEmails.php'); interface Responder { public function respond(Salutable $receiver, $response); public function getResponderName(); } class WiseAssResponder implements Responder { protected $responderName; public function __construct($responderName) { $this->responderName = $responderName; } public function getResponderName() { return $this->responderName; } public function respond(Salutable $receiver, $response) { echo "Hi " . $receiver->getSalutationName() . ". Please read my response below: \n\n"; echo $response; echo "Kindest Regards,\n" . $this->getResponderName(); } } class Martin implements Salutable { public function getSalutationName() { return get_class($this); } } $martin = new Martin(); $johnW = new WiseAssResponder('John W'); $response=<<<HEREDOC Well I'm not going to argue with you that there is plenty of crap code out there. PHP or not. OOP or not. And I'm all for taking OOP in PHP seriously, but I also think it's worth keeping in mind that the real power in PHP is not it's object oriented capabilities, but rather its simplicity and flexibility. And, well, I don't know if your Hello, World example keeps that in mind.
I'd rather say that we have different concepts of what is simple and flexible, and both concepts are aceptable. I know that plenty of people on this list want to have a serious
conversation about OOP for PHP (should we just start using OOPHP as the new acronym? or maybe POOPH? Or... PHOOP?!? Wait, that's not taking thing seriously...), but I don't think a complex Hello, World made of Saluters, Salutables, factories and abstractions is taking it serious. I think it's exhausting the theory and using various design patterns for the sake of using design patterns...
It seems we've differents approaches to what is complex and what is simple (in terms of computer systems). I think being serious about OOP is start thinking even the simplest of problem from an OOP perspective. I just exposed the Hello World as an example, off course it seems like using a nuke to kill a mosquito, but here I'm not thinking about efficiency or efficacy, it's about training the mind into the OOP methodologies and ways of thinking. Like training your body, once the mind sees everything in terms of object abstraction, OOP will be as natural as breathing. The kind of thinking that OOP it's just a *super* feature of a programming language that should be used only for highly complex problems, is what I want to eradicate. OOP doesn't stand neither as a language feature nor as extra capabilities of a language, on the contrary, it takes some freedom away from the programmer. I see OOP as a way of thinking and working, that should be used in the most complex problem and the most simple problem equally. But really all of this comes down to the imutable truth about
programming in PHP: there are a *million* ways to skin a cat. When you heard "OOP + Hello, World", you thought about people/things greeting each other. When I heard it, I thought about an application outputing a string. The guy who started that particular thread probably thought of something totally different. Who's to say who is right?
Off course, no one can say which is the right way to solve a problem, and I will not hide the fact that OOP is just a coder's whim. I'm just inviting you over to this whim, I can assure you that it's a healthy and beneficial whim, it's not just a Java hype. At least it's healthier whim than web2.0. Hey, take my words as mine alone though. Maybe I was the only one
that got my joke. It's happened before.
Nope, I caught your joke, and I found it amusing. Though every joke hides a truth, as I can explain a hello world in oop laughing and being serious at the same time. HEREDOC;
$johnW->respond($martin, $response); exit; [/code]