NYCPHP Meetup

NYPHP.org

OO - when classes are related, who gets which method?

Chris Snyder chris at psydeshow.org
Tue Jun 10 19:15:51 EDT 2003


I've got a question for anyone who's an old hand at object-oriented 
programming, or for any new hands with opinions:

Let's say I have a class named Object, and I want to create another 
class that is related to it named Related. I figure I can construct 
Relateds in either of two ways:

$related = $object->createRelated();
or
$related = new Related; $related->create(&$object);

Is there a general rule of thumb that will tell me which is the better 
way to implement this?

The first looks simpler, but something tells me the second is better 
form, because it keeps the creation method inside the class.

    chris.





More information about the talk mailing list