Re: Re: OOP Hello World

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 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...

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?

Hey, take my words as mine alone though.  Maybe I was the only one
that got my joke.  It's happened before.

HEREDOC;

	$johnW->respond($martin, $response);
	exit;
[/code]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux