
Originally Posted by
McGruff
I've been through OOP v procedural debates too many times to remember. The only constant theme is that it always - always - turns out that the anti-OOP brigade do not have enough experience of OOP to criticise it properly (and none at all of testing).
I'm one of those with little experience, yet I've come to love OOP (reading the code excerpts on the regular PHP forum here is really painful now). So I hesitate to respond to someone with McGruff's credentials
Snaily may correct me if I'm wrong, but I sense that his (her?) comment was about "degree". If I may present an example, in Selkirk's CRUD example in WACT...
PHP Code:
$Front = new PathInfoDispatchController();
$Front->addChild('index', new Handle('IndexPage', APP_LIB_ROOT . 'phpmodule/index.page.php'));
$Front->addChild('details', new Handle('DetailsPage', APP_LIB_ROOT . 'phpmodule/details.page.php'));
$Front->addChild('delete', new Handle('DeletePage', APP_LIB_ROOT . 'phpmodule/delete.page.php'));
$Front->addChild('edit', new Handle('EditPage', APP_LIB_ROOT . 'phpmodule/edit.page.php'));
$Front->addChild('add', new Handle('AddPage', APP_LIB_ROOT . 'phpmodule/add.page.php'));
$Front->setDefaultChild('index');
$Front->start();
Add each child in turn (there's a sniff of the procedural about this, even though those objects don't immediately do anything). Should Selkirk have created a class called CrudApplication and wrapped all of this in it?
PHP Code:
$crud = new CrudApplication();
$crud->execute();
Where would you draw the line?
I tend to see the greatest benefit of OOP as being organisation. One might have to dive in and out of lots of files to follow the action (as it were), but it sure is easier to inspect a class method than to scroll a couple of hundred lines to see where a variable might have been set. Lastcraft has frequently alluded to the "expressiveness" of OOP, provided one names objects sensibly. Is this partly what those from a computer science background mean by "encapsulation" or is it simply separation of concerns?

Originally Posted by
McGruff
I think it's fair to challenge statements in a technical discussion. Also to question if an individual is qualified to comment in the first place. It's not an easy subject and people who do often aren't.
Well, that would be me again. But if I make such uninformed statements and someone like McGruff makes a counter-argument, I may be disabused of whatever silly notion I expressed. So McGruff may bemoan the airing of certain prejudices, but the potential for greater understanding or exploration of issues always exists.
Bookmarks