Page 4 of 6

Posted: Mon Mar 07, 2005 8:09 pm
by McGruff
timvw wrote:I don't think phpBB was really designed, more that it evolved into something unmaintainable ... But i doubt it that with an oop implementation there wouldn't have been a maintenance problem.
Admittedly phpBB is an extreme example.

There is always maintenance but it's much, much easier with a well-designed, nicely-encapsulated, unit-tested system.

Posted: Tue Mar 08, 2005 8:07 pm
by Roja
McGruff wrote: I do think it's important to make the point that, almost without exception, the whole thing just sounds naive to more experienced programmers. In fact, you're the only one I know who doesn't seem to think so. Where people stand on the OOP "debate" is almost a litmus test of their programming knowledge.
Rasmus Lerdorf wrote: There is nothing wrong with mixing OOP and procedural code in PHP. Use objects when they make sense, and go procedural for the rest.
http://www.oracle.com/technology/pub/ar ... s_php.html

Is he inexperienced or naive?

His point of view seems to mirror most of the responses here - I havent seen anyone really say "OOP should never be used", although I do see some saying procedural should be avoided at all costs, which clearly, some experienced programmers disagree with. :)

Posted: Tue Mar 08, 2005 9:20 pm
by McGruff
That's hardly an in-depth assessment of OOP in php. It looks more like a throw-away beginner's tutorial comment. I wouldn't disagree with it too much, in that context.

I wouldn't know what sort of design sophistication he has in general. His guide to structuring a large php application certainly isn't very insightful but then there isn't room to say much in one article.

Posted: Tue Mar 08, 2005 10:38 pm
by Buddha443556
Rasmus Lerdorf wrote:There is nothing wrong with mixing OOP and procedural code in PHP. Use objects when they make sense, and go procedural for the rest.

McGruff wrote:That's hardly an in-depth assessment of OOP in php. It looks more like a throw-away beginner's tutorial comment. I wouldn't disagree with it too much, in that context.
No that's pretty much discribes Rasmus Lerdorf, the creator of PHP, stand on the subject at least from what I've read. :roll:

Posted: Wed Mar 09, 2005 6:36 pm
by McGruff
I suspect he would have more to say than you are giving him credit for. If he really were saying that procedural is as powerful as OOP he'd be wrong - simple as that.

Let me put the "OOP as programming intelligence indicator" argument another way. It would be fair to expect someone who's never been to America not to write travel guides about the place. A flying visit to Disneyland won't do either. You can't "learn OOP in two weeks" as another poster once famously claimed.

Others can pick their own lists but off the top of my head suppose the discussion were restricted to people who:

(1) Have a well-thumbed copy of PoEEA (probably within arms reach) and would be able to write a critique of at least one of the patterns therein, pointing out possible flaws and improvements.
(2) Have maintained a non-OOP php application and an OOP one for a period of at least a year.
(3) Are experienced users of one of the php unit-testing frameworks.

How many people do you think would still be in the discussion..?

Posted: Wed Mar 09, 2005 10:42 pm
by McGruff
Please note that I've already warned one member who shall remain nameless about personal comments in a now deleted post. Say what you like but stick to programming.

Posted: Thu Mar 10, 2005 12:27 am
by AGISB
So McGruff likes to do it all OOP. Fine
Others like to use a mixture. Fine

It's all about preferences and nothing to get personal about. I also disagree that the use amount of OOP reflects the skill of the programmer. I think the skill of the programmer is reflected by the way someone finds the best possible coding for any given problem. If this is OOP fine but if it is procedural there is no reason to use OOP just for the sake of it.

Posted: Thu Mar 10, 2005 12:36 am
by infolock
The only time I ever see the need or want to use OOP is when there is a LOT of redundant code being used in multiple files. As the above said, usage of OOP is not necessarily a reflection on the skill, but merely a better alternative when you are having to manage say 40 scripts for one app...

So, the epos thing i was fooling with is a prime example. It had multiple connection calls, multiple checks on databases and other types of updates that would be made based on what was entered. instead of writing the same exact 30 lines of code in every single one of my files, i migrated (or at least began migrating) most over into one class file.

That by no means makes me a better programmer, however it makes the application a lot easier to manage and less cluttered..

To each his own though.

Posted: Thu Mar 10, 2005 2:29 am
by patrikG
a small tip from someone who has seen so many of these OOP vs. Prodcedural debates that I could recite them backwards while reading Nietzsche: don't make it personal.

Posted: Thu Mar 10, 2005 8:24 am
by McGruff
You are certainly free to choose. One of php's strengths is that it offers a low and easy entry point.

But my point is that most people do not make any real choice. They're just sticking with what they know. The mountains on the horizon have been there for so long they feel familiar but they've never actually been there and crawled all over them.

If you've got the curiosity and ambition to learn more, there is much more to learn about. It's not easy at first but it's much more interesting and has lots of fun eureka moments.

Posted: Thu Mar 10, 2005 9:13 am
by Buddha443556
McGruff wrote:I suspect he would have more to say than you are giving him credit for. If he really were saying that procedural is as powerful as OOP he'd be wrong - simple as that.
In Lerdorf's quote, he didn't say anything about OOP being more or less powerful than procedural. He said use both just like many others in this thread.

Any technology is only as powerful as the programmer or programmers applying it. The more knowledgeable the programmers the better they can apply a technology.

The patterns in PoEAA were around a long time before anyone thought to put them in a book and were in use even before a there was an OOPL.

I have no idea why someone would limit them self by limiting their knowledge?
patrikG wrote: ... don't make it personal.
Maybe a new forum rule barring religious debates would help? :wink:

Posted: Thu Mar 10, 2005 9:18 am
by patrikG
/derail on
Buddha443556 wrote:
patrikG wrote: ... don't make it personal.
Maybe a new forum rule barring religious debates would help? :wink:
Hehe, and a rule about not being allowed chewing chewing-gum while posting on or reading this board ;)

/derail off

Posted: Thu Mar 10, 2005 9:48 am
by McGruff
OK. Forget what Rasmus has or hasn't said. Of course you have a choice in the sense that you can travel to work by bicycle or you can learn to drive and use a car. Do we agree that OOP is more powerful?

Some of the PoEEA patterns might be do-able procedurally but many simply don't make sense (Object-Relational mapping..). Some you might find rather difficult without encapsulation eg Gateways and ServiceLayers.

I have to ask, have you read the book?

I brought up PoEEA in the first place because OOP is much more than just knowing the syntax to define a class. It's about making the effort to truly understand what's going on in your scripts, separating the different threads into discrete units of functionality all the way down from the presentation/domain/data layering to the myriad groups of co-operating objects within each layer. It all gets quite pattern heavy and it's exactly this kind of conceptual richness that makes OOP so powerful. PoEEA is one of the classic texts on the subject.

There's no disgrace in not being familiar with advanced OOP theory. You'll find a lot of people will be glad to share their knowledge and enthusiasm if you're willing to learn. But, out of respect for basic intellectual standards and for learner programmers who might be misled, I'm taking no prisoners.

Posted: Thu Mar 10, 2005 10:03 am
by Roja
McGruff wrote:I suspect he would have more to say than you are giving him credit for.
Sorry, but thats really his position - he's been quoted a number of times on that point. Here's another:
Rasmus also shared some hints on optimising PHP code. Essentially you should try to keep the includes to a minimum, use OOP techniques only where appropriate, and the same for layers, abstractions, etc.
McGruff wrote: If he really were saying that procedural is as powerful as OOP he'd be wrong - simple as that.
Lets look at it the opposite way: Many people here (including the language's creator!) are saying "use what works, including oop".

You on the other hand have said:
With respect to previous posters, it's not a matter of personal preference. There is simply no comparison between OOP and procedural. You cannot approach anything like the power of OOP with other methods.
and
Everything should be an object
And so on.

You and timvw seem to be the only ones supporting that point of view - a decidedly divisive point of view!

Which is why I have great pause when you say "dont make it personal" - because instead, you are making over-generalizations about anyone that disagrees with that point of view.

You make characterizations like:
There is so much nonsense talked about the subject on the internet and I don't like to see learner programmers being misled.
And
the whole thing just sounds naive to more experienced programmers
The position that is divisive is yours. Everyone seems to be making reasonable statements (ala "Use what works", "Use oop when you can"), and you two seem to be unwilling to accept that anyone experienced (including another high-post-count moderator, and one of the authors of the language!) could possibly disagree that oop is always better than procedural code.

I have plenty of experience. I meet all three criteria you mention (depending on how you interpret your phrasing), and there is plenty to discuss.

But when you equate anyone that doesnt agree with the position that OOP is always better as being inexperienced or unintelligent ("oop is a programming intelligence indicator", indeed), you force it to BECOME a personal issue, with people defending their honor, their experience, and their point of view against your libel and accusations.

I'm certainly not trying to make it personal, but in four threads, the only post that I see that agrees in principle ("OOP is really the only choice") is feyd's. All other posts seem to be pragmatic.

If you want people not to make it personal, then please explain how your comments avoided making it personal, and further, what entitles you to libel anyone that disagrees in a gross over-generalization.

Posted: Thu Mar 10, 2005 10:18 am
by feyd
In a compiled language, I would more agree with McGruff that OOP is about the only way things should be done..

However, PHP is not a compiled language. So when the interpreter has to run over lots of OOP stuff, it does add more time. If speed is critical, procedural code will often be faster. Not necessarily by much, but every little bit helps. If maintainability, upgradability, and/or flexibility is more critical, then OOP is a good direction to head. At the very least, seperation of presentation from logic is often critical at that level.