[jihad] oop vs procedural
Moderator: General Moderators
From an email sent to a member who shall remain nameless, a final word on the recent troubles:
I strongly agree that php's flexibility is a huge strength - I might never have begun learning to code if it wasn't so easy to get started. But the flip side of this is that a huge amount of php code is badly written, including many popular php apps. Not badly written in the sense that they don't work, but badly written in that there is a very poor separation of concerns thus making them difficult to edit and maintain. I think it is important to try to point people towards the best modern programming practices like OOP, unit testing, XP and so on. That's not an official policy but it is where I concentrate my own efforts on these forums.
Many problems in forum posts fundamentally arise from a poor separation of concerns: it is a great help to be shown how to fix a specific bug but another one is going to come along tomorrow if you don't start learning about script design. With OOP (and testing) a whole series of fiddly, frustrating problems are swapped for a new set of abstract design problems of course, but at least these are more interesting and creative - and above all more empowering. I know that you can take a stab at these issues with other means but my own belief is that they aren't anything like as effective.
Some of our members will be thinking about a programming career: professional programmers have to learn this stuff (I'm still learning myself). For those who dislike OOP, you're still going to have to learn it properly in order to argue convincingly against it. There is no escape
OOP advocates aren't bigots: but we do believe that OOP is almost always a better and more powerful tool and also that this isn't just a question of style but rather a fact which can be demonstrated. We do think that people who argue against this may not have fully grasped what is after all quite a difficult discipline (and I make no claims to be an expert myself). These are strong words I know which require to be backed up by strong arguments. I can understand if that can be provocative to the other camp.
Neveretheless, that's where we are. Let that provoke only debate. It is possible to explore these different ideas in a spirit of intellectual inquiry. Anyone can promote their point of view here so long as they are saying things like "I think that idea A is mistaken because of x, y and z". If you're prepared to be reasonable you won't have a problem but I am determined not to allow these discussions to degenerate into fractious disputes. OOP v procedural can be almost as bad as politics and religion and there will be a twenty ton concrete block waiting in the middle of the road for anyone who starts getting personal. I'm not going to take it myself, and I'm not going to allow anyone else to be attacked.
I strongly agree that php's flexibility is a huge strength - I might never have begun learning to code if it wasn't so easy to get started. But the flip side of this is that a huge amount of php code is badly written, including many popular php apps. Not badly written in the sense that they don't work, but badly written in that there is a very poor separation of concerns thus making them difficult to edit and maintain. I think it is important to try to point people towards the best modern programming practices like OOP, unit testing, XP and so on. That's not an official policy but it is where I concentrate my own efforts on these forums.
Many problems in forum posts fundamentally arise from a poor separation of concerns: it is a great help to be shown how to fix a specific bug but another one is going to come along tomorrow if you don't start learning about script design. With OOP (and testing) a whole series of fiddly, frustrating problems are swapped for a new set of abstract design problems of course, but at least these are more interesting and creative - and above all more empowering. I know that you can take a stab at these issues with other means but my own belief is that they aren't anything like as effective.
Some of our members will be thinking about a programming career: professional programmers have to learn this stuff (I'm still learning myself). For those who dislike OOP, you're still going to have to learn it properly in order to argue convincingly against it. There is no escape
OOP advocates aren't bigots: but we do believe that OOP is almost always a better and more powerful tool and also that this isn't just a question of style but rather a fact which can be demonstrated. We do think that people who argue against this may not have fully grasped what is after all quite a difficult discipline (and I make no claims to be an expert myself). These are strong words I know which require to be backed up by strong arguments. I can understand if that can be provocative to the other camp.
Neveretheless, that's where we are. Let that provoke only debate. It is possible to explore these different ideas in a spirit of intellectual inquiry. Anyone can promote their point of view here so long as they are saying things like "I think that idea A is mistaken because of x, y and z". If you're prepared to be reasonable you won't have a problem but I am determined not to allow these discussions to degenerate into fractious disputes. OOP v procedural can be almost as bad as politics and religion and there will be a twenty ton concrete block waiting in the middle of the road for anyone who starts getting personal. I'm not going to take it myself, and I'm not going to allow anyone else to be attacked.
It's good that you agree with it as there is no denying that it's flexibility and ones ability to easily grasp it has everything to do with it's success. There is an interesting phenomena in that many of these simple and flexible things have risen to the fore in recent history. Windows and MySQL are two good examples. PHP is more of the same.McGruff wrote: I strongly agree that php's flexibility is a huge strength - ...
There are legions of people that say just this. However, are we trying to step through and close the door behind us? Let 'em in! Just like kids, noob3's are going to make a mess here and there. It's all part of learning.I might never have begun learning to code if it wasn't so easy to get started.
Ultimately, we are better off to encourage exploration and mess making.
These are design issues. Not paradigm problems. If one grasped these issues merely by understanding OOP, things like the GOF design patterns book would have no need to exist. If you take a look at that grey-around-the-edges thing called the past, you can see that this was being dealt with long before OOP came to the popular fore. The idea of modules is a prime example as such. Even the record or struct can be seen as part of the march towards OOP.But the flip side of this is that a huge amount of php code is badly written, including many popular php apps. Not badly written in the sense that they don't work, but badly written in that there is a very poor separation of concerns thus making them difficult to edit and maintain. I think it is important to try to point people towards the best modern programming practices like OOP, unit testing, XP and so on. That's not an official policy but it is where I concentrate my own efforts on these forums.
But even still, and this is the most important fact anyone can realize, OOP is not Object Oriented Design! Without OOD, OOP is the same old bad practices revisited.
And to take it even further, you don't need an OOP language to use OOD.
So the real kicker here is that OOP merely facilitates OOD. Once this distinction is understood, then all other ranting becomes nothing more than bull*&^%!
RDD (Responsibility Driven Design) is another important stepping stone in the march towards good design. Your term, "poor seperation of concerns" is basically a failure to identify and associate responsibilies or behaviours to given blocks of code. Here is Timothy Budd's explanation of 'Characterization by Behaviour'.Many problems in forum posts fundamentally arise from a poor separation of concerns:...
That said, people (procedural and OOP alike) fail to do this all the time. The nice thing about OOP is that it encourages you to think in more of an OOD fashion. But even still, RDD and OOD can be applied to any language or paradigm. I can call any data structure I want an object if it helps clarify and facilitate the design and understanding of a larger system. To get caught up in the question of whether or not it's a real object is to allow one self to be mired in legality or the 'letter' as opposed to the spirit. And if that's the case, where has the flexibility gone?Timothy Budd wrote: * First capture behaviour of application
* Refine this into behaviour of subsystems
* Refine behaviour descriptions into code
I like to think of myself as a professional, but for many of the things I've done, OOP is complete and utter overkill. To imply that OOP makes sense in all or the majority of situations is to promote a Golden Hammer way of thinking (http://c2.com/cgi/wiki?GoldenHammer). Most craftsmen have multiple tools and never leave all but one in the truck!Some of our members will be thinking about a programming career: professional programmers have to learn this stuff (I'm still learning myself). For those who dislike OOP, you're still going to have to learn it properly in order to argue convincingly against it. There is no escape![]()
I'm an OOP advocate, but I DO NOT believe that OOP is almost always a better and more powerful tool.OOP advocates aren't bigots: but we do believe that OOP is almost always a better and more powerful tool and also that this isn't just a question of style but rather a fact which can be demonstrated.
Are you then implying that my knowledge of this is lacking?We do think that people who argue against this may not have fully grasped what is after all quite a difficult discipline (and I make no claims to be an expert myself). These are strong words I know which require to be backed up by strong arguments. I can understand if that can be provocative to the other camp.
The truth here is that this thing started over a some ballyhoo'ing about what was said by Tony Marston. The truth of the matter is that he and others have some valid concerns becuase they see certain practices making themselves known again. As an example, here is something Fabian Pascal had to say...
Take from that what you will, but if you really read some of his other rantings and come back to comments by Tony Marston, you begin to see what their frustration is. Furthermore, notice that his last couple of sentences talk about complex data types. This is an area in the PHP community where I hear very little talk. And not just of complex data types (data structures), but algorithms as well. So if we just tell all noobs "Learn OOP and prosper", we are ultimately doing them a disservice. Without a clear understanding of this topic and it's ramifications, then it's inevitable that the thing Tony Marston complained about will come to pass in the practice of these developers: An extension of an OOP centric view to data management.Fabian Pascal wrote: Like object DBMS before it, XML has all the hallmarks of becoming the next industry fad, among them proliferation of articles, books and conferences on the subject and vendors stepping over each other to provide some sort of XML "support". Well, to a hammer everything may look like nails, but whether programmers and web developers like it or not, the fact is that not everything is nails and treating everything as nails will not work. A DBMS is not program and a data language is not a document description language and there is ample knowledge and experience to show that treating them as such causes severe problems. Unfortunately, programmers and web developers are not familiar with data management fundamentals. Those forgetting the past are doomed to relive it.
Because XML is advanced as a data management solution, the only way to assess its suitability to task is from a data management perspective. One particular kind of XML support are DBMS "extenders", a form of so-called "complex" data types (documents). This is the DBMS vendors' response to criticism of RDBMS (more precisely SQL DBMS) products as poor supporters of such data types. Unfortunately, the data type concept is one of the least understood even by database practitioners. This is both the cause and the consequence of the failure by SQL and its commercial implementations to support relational domains, which are nothing but data types of arbitrary complexity. Without a good understanding of data types it is impossible to assess any implementation of "complex" types, be it XML or any other types....
Now saying that is not to imply OOP sucks. It's a warning to not take it to far. To not extend the mentality or practice to areas it doesn't belong. Plain and simple as that. Now Mr. Marstons <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span> and vinegar makes it hard to see that (and he does imply more btw), but once you strain out the condescending crap (same with Mr Pascal), there is some good data there.
As for the idea of taking it too far, one of these days I'll get around to posting the schema for a project where this was the case. While the code was procedural, they took an aproach to a heirarchal approach to data management. Furthermore, they stored these object heirarchies in a relational system (MySQL). To top it off, they seemed more as people that had just stumbled across these concept. The lead developer had no knowledge even of what a tree was and never even knew that all that fancy logic needed to get information out of the system was called traversal.
Man am I glad I don't have that job anymore.
Now none of what I posted was meant as an attack. Please don't take it as such. I too use OOP and am an advocate of it's use where it's use makes sense. And the question of where it makes sense should be left to the developer and his mission at hand.
No need to apologise that's not a rant in my book. I've heard you say similar things before and I really am genuinely interested in how one might match the power of OOP using other means of OOD.
You asked if I was implying your knowledge was lacking. It might be. Or mine might be. Who cares? The point is that one or other - or both - of us, or anyone else reading these public discussions, might have something to learn. That's what we're here for. That's what discussion should be all about. I was just trying to be honest, trying to acknowledge the potential for conflict which exists and so possibly take some of the sting out of it. Conflict needn't be feared if this is seen as an oportunity for an interesting discussion. I may well have to modify my own positions - I'm prepared to do that.
One thing that is clear is that Tony Marston has a lot to learn as you can also see here: http://www.sitepoint.com/forums/showthread.php?t=208947. It's a long read but for example saying that he doesn't need to read the classic texts and then displaying complete ignorance of the problems they address does not qualify him to sound off about script design.
We wouldn't be human if we didn't have an ego but it's sad when this restricts one's ability to learn. Intelligence is a gift and knowledge should be cherished. This is why I've been so firm in this topic. The rest is just "white noise" which limits the opportunity for a good debate.
You asked if I was implying your knowledge was lacking. It might be. Or mine might be. Who cares? The point is that one or other - or both - of us, or anyone else reading these public discussions, might have something to learn. That's what we're here for. That's what discussion should be all about. I was just trying to be honest, trying to acknowledge the potential for conflict which exists and so possibly take some of the sting out of it. Conflict needn't be feared if this is seen as an oportunity for an interesting discussion. I may well have to modify my own positions - I'm prepared to do that.
One thing that is clear is that Tony Marston has a lot to learn as you can also see here: http://www.sitepoint.com/forums/showthread.php?t=208947. It's a long read but for example saying that he doesn't need to read the classic texts and then displaying complete ignorance of the problems they address does not qualify him to sound off about script design.
We wouldn't be human if we didn't have an ego but it's sad when this restricts one's ability to learn. Intelligence is a gift and knowledge should be cherished. This is why I've been so firm in this topic. The rest is just "white noise" which limits the opportunity for a good debate.
Indeed.McGruff wrote:The point is that one or other - or both - of us, or anyone else reading these public discussions, might have something to learn. That's what we're here for. That's what discussion should be all about.
And I sincerely thank everyone for the contribution to this thread and many others around these forums. These are some of the most educational and intriguing discussions around, and I'm sure many people will find your discussions very informative and valuable to their knowlege of the web development industry.
So once again, thank you.