Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #5385 > unrolled thread
| Started by | "Mr. B-o-B" <mr.chew.baka@gmail.com> |
|---|---|
| First post | 2012-04-09 14:35 -0500 |
| Last post | 2012-04-12 13:18 -0400 |
| Articles | 20 on this page of 28 — 11 participants |
Back to article view | Back to comp.lang.php
OOP versus Procedural/Functional "Mr. B-o-B" <mr.chew.baka@gmail.com> - 2012-04-09 14:35 -0500
Re: OOP versus Procedural/Functional "J.O. Aho" <user@example.net> - 2012-04-09 21:59 +0200
Re: OOP versus Procedural/Functional The Natural Philosopher <tnp@invalid.invalid> - 2012-04-09 22:46 +0100
Re: OOP versus Procedural/Functional Michael Vilain <vilain@NOspamcop.net> - 2012-04-09 19:29 -0700
Re: OOP versus Procedural/Functional Jerry Stuckle <jstucklex@attglobal.net> - 2012-04-09 16:55 -0400
Re: OOP versus Procedural/Functional "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-04-10 00:34 +0200
Re: OOP versus Procedural/Functional Goran <goran@nospam.com> - 2012-04-10 10:14 +0200
Re: OOP versus Procedural/Functional "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-04-10 12:06 +0200
Re: OOP versus Procedural/Functional The Natural Philosopher <tnp@invalid.invalid> - 2012-04-10 13:04 +0100
Re: OOP versus Procedural/Functional Tim Streater <timstreater@greenbee.net> - 2012-04-10 16:07 +0100
Re: OOP versus Procedural/Functional The Natural Philosopher <tnp@invalid.invalid> - 2012-04-10 16:28 +0100
Re: OOP versus Procedural/Functional Jerry Stuckle <jstucklex@attglobal.net> - 2012-04-10 12:08 -0400
Re: OOP versus Procedural/Functional "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-04-10 19:14 +0200
Re: OOP versus Procedural/Functional The Natural Philosopher <tnp@invalid.invalid> - 2012-04-10 18:19 +0100
Re: OOP versus Procedural/Functional Michael Fesser <netizen@gmx.de> - 2012-04-10 14:49 +0200
Re: OOP versus Procedural/Functional "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> - 2012-04-10 17:29 +0200
Re: OOP versus Procedural/Functional The Natural Philosopher <tnp@invalid.invalid> - 2012-04-10 16:34 +0100
Re: OOP versus Procedural/Functional crankypuss <no@email.thanks> - 2012-04-11 05:16 -0600
Re: OOP versus Procedural/Functional Goran <goran@nospam.com> - 2012-04-11 16:25 +0200
Re: OOP versus Procedural/Functional Jerry Stuckle <jstucklex@attglobal.net> - 2012-04-11 13:06 -0400
Re: OOP versus Procedural/Functional Tim Streater <timstreater@greenbee.net> - 2012-04-11 18:18 +0100
Re: OOP versus Procedural/Functional Jerry Stuckle <jstucklex@attglobal.net> - 2012-04-11 16:24 -0400
Re: OOP versus Procedural/Functional Tim Streater <timstreater@greenbee.net> - 2012-04-11 22:43 +0100
Re: OOP versus Procedural/Functional crankypuss <no@email.thanks> - 2012-04-12 05:54 -0600
Re: OOP versus Procedural/Functional "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-04-11 19:09 +0200
Re: OOP versus Procedural/Functional crankypuss <no@email.thanks> - 2012-04-12 05:56 -0600
Re: OOP versus Procedural/Functional "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-04-12 17:33 +0200
Re: OOP versus Procedural/Functional Jerry Stuckle <jstucklex@attglobal.net> - 2012-04-12 13:18 -0400
Page 1 of 2 [1] 2 Next page →
| From | "Mr. B-o-B" <mr.chew.baka@gmail.com> |
|---|---|
| Date | 2012-04-09 14:35 -0500 |
| Subject | OOP versus Procedural/Functional |
| Message-ID | <alpine.LNX.2.00.1204091428210.3668@mobile_yoda.darkside> |
I was curious about peoples thoughts in regards to OOP with PHP. Are there pro's/con's of writing OOP code versus procedural/functional coding? Strictly speaking for PHP, I do the bulk of my coding as procedural/functional. I really haven't found any added benefit to going the OOP route. Am I missing something, or is it just a different approach to the same problem? Thanks! Mr. B-o-B
[toc] | [next] | [standalone]
| From | "J.O. Aho" <user@example.net> |
|---|---|
| Date | 2012-04-09 21:59 +0200 |
| Message-ID | <9ugtdvFqubU1@mid.individual.net> |
| In reply to | #5385 |
Mr. B-o-B wrote: > I was curious about peoples thoughts in regards to OOP with PHP. > > Are there pro's/con's of writing OOP code versus procedural/functional coding? > > Strictly speaking for PHP, I do the bulk of my coding as > procedural/functional. I really haven't found any added benefit to going the > OOP route. There is two minds about OOP, there are those who thinks is the way to go and those who thinks it don't give any benefits. > Am I missing something, or is it just a different approach to the same problem? It's another way to solve the problem and there is a third way which kind of mixes both worlds. Read some more about OOP in general and get a bit better insight for example: http://www.inf.ufsc.br/poo/smalltalk/ibm/tutorial/oop.html The site may or may not be good, just got it as a hit on google, never read it myself. If you get an aha-moment, then OOP maybe is something for you, but if you feel it's just making things complicated, than stay with traditional functional programming. Many of the major big projects uses OOP, so it can be a good point in knowing how it works. -- //Aho
[toc] | [prev] | [next] | [standalone]
| From | The Natural Philosopher <tnp@invalid.invalid> |
|---|---|
| Date | 2012-04-09 22:46 +0100 |
| Message-ID | <jlvlc0$svp$1@news.albasani.net> |
| In reply to | #5386 |
J.O. Aho wrote: > Mr. B-o-B wrote: >> I was curious about peoples thoughts in regards to OOP with PHP. >> >> Are there pro's/con's of writing OOP code versus procedural/functional >> coding? >> >> Strictly speaking for PHP, I do the bulk of my coding as >> procedural/functional. I really haven't found any added benefit to >> going the >> OOP route. > > There is two minds about OOP, there are those who thinks is the way to > go and those who thinks it don't give any benefits. > > > >> Am I missing something, or is it just a different approach to the same >> problem? > > It's another way to solve the problem and there is a third way which > kind of mixes both worlds. > > Read some more about OOP in general and get a bit better insight for > example: > http://www.inf.ufsc.br/poo/smalltalk/ibm/tutorial/oop.html > > The site may or may not be good, just got it as a hit on google, never > read it myself. > > If you get an aha-moment, then OOP maybe is something for you, but if > you feel it's just making things complicated, than stay with traditional > functional programming. > > Many of the major big projects uses OOP, so it can be a good point in > knowing how it works. > My research indicated that while it was definitely better for certain things - VERY large projects being one of them, it wasn't worth the hassle of doing it on small stuff. I know of at least one company director who told me 'we wouldnt have lost the business if we had decided NOT to write it in object oriented code' By the time they realised the cruciality of proper pre code object definitions, it was too late and you cant hack OO like you can procedural. I think if the project warrants the sort of intense functional decomposition and 'objectification' process and there are dozens of coders working on it, its a clumsier but more safe way to get slowly to a working solution. Like designing a database, you need to be clear on what objects you are going to use and what operations you will perform on them and the impact (relations) you want to have on other objects. You can use an OO approach without actually using the language extensions - E.g, in terms of files with defined (function) entry points and static internal data.. The approach is worth studying: whether you want to force *all* your code into the mould and/or use OOP language extensions is a moot point. The step from machine code to assembler is like 100, from assembler to macro assembler is like 10, from macro assembler to a language like C is about 1 and from C to C++ is about 0.1 in my opinion. I.e its a question of diminishing returns every time. -- To people who know nothing, anything is possible. To people who know too much, it is a sad fact that they know how little is really possible - and how hard it is to achieve it.
[toc] | [prev] | [next] | [standalone]
| From | Michael Vilain <vilain@NOspamcop.net> |
|---|---|
| Date | 2012-04-09 19:29 -0700 |
| Message-ID | <vilain-3628A9.19290109042012@news.individual.net> |
| In reply to | #5386 |
In article <9ugtdvFqubU1@mid.individual.net>, "J.O. Aho" <user@example.net> wrote: > Mr. B-o-B wrote: > > I was curious about peoples thoughts in regards to OOP with PHP. > > > > Are there pro's/con's of writing OOP code versus procedural/functional > > coding? > > > > Strictly speaking for PHP, I do the bulk of my coding as > > procedural/functional. I really haven't found any added benefit to going > > the > > OOP route. > > There is two minds about OOP, there are those who thinks is the way to go and > those who thinks it don't give any benefits. > > > > > Am I missing something, or is it just a different approach to the same > > problem? > > It's another way to solve the problem and there is a third way which kind of > mixes both worlds. > > Read some more about OOP in general and get a bit better insight for example: > http://www.inf.ufsc.br/poo/smalltalk/ibm/tutorial/oop.html > > The site may or may not be good, just got it as a hit on google, never read > it > myself. > > If you get an aha-moment, then OOP maybe is something for you, but if you > feel > it's just making things complicated, than stay with traditional functional > programming. > > Many of the major big projects uses OOP, so it can be a good point in knowing > how it works. OK. I thought I was missing something by not immediately jumping on the OOP bandwagon. My first language was FORTRAN and a friend had to tell me about 'automatic variables' when I had a particularly annoying problem that worked in FORTRAN but failed in C. I picked up the php version of OOP because it made more sense to me than Perl's implementation. There's to much of Perl I have yet to learn but I was reasonably able to pick up php 4 and php 5's OOP model and get it working on small stuff. Then I tried to get something bigger (phpBB), it was an interesting mess of both procedural and OOP. I stand by the "use what works when needed" rule. Sometimes it's a ball peen hammer. Sometimes a sledge. Sometimes bazooka. -- DeeDee, don't press that button! DeeDee! NO! Dee... [I filter all Goggle Groups posts, so any reply may be automatically ignored]
[toc] | [prev] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2012-04-09 16:55 -0400 |
| Message-ID | <jlvibb$lcl$1@dont-email.me> |
| In reply to | #5385 |
On 4/9/2012 3:35 PM, Mr. B-o-B wrote: > I was curious about peoples thoughts in regards to OOP with PHP. > > Are there pro's/con's of writing OOP code versus procedural/functional > coding? > > Strictly speaking for PHP, I do the bulk of my coding as > procedural/functional. I really haven't found any added benefit to going > the OOP route. > > Am I missing something, or is it just a different approach to the same > problem? > > Thanks! > > Mr. B-o-B > > > > > It is another approach, and like any approach, it has its advantages and disadvantages. One of the big advantages is you can put all of your validation code in the class - for instance, if you have a User class with username, password and email, the three fields can be validated in the class itself. This means all of your validation for the three fields is in one place. The class itself is bigger, but there's less duplication of code (i.e. you don't have to verify the password when they sign up or when they try to change their password). Overall, you typically end up with fewer lines of code and fewer bugs due to the less duplication. And properly designed, you could take this User class and drop it into another website unchanged, so you already have all the information available. Other advantages are things like isolating database calls from the rest of the program - put all of your database-specific stuff in a class, then the class object represents the connection to the database. The mysqli_xxx interface is a good example of this for MySQL. You can simulate OO with just functional coding, but you don't get the full advantages of OO unless you design your code to use OO. With that said - I like OO, but I still do functional programming also. Like anything else, neither is best in every instance. Your best bet is to become familiar with OO and try it out. See where it will work for you and where it won't. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ==================
[toc] | [prev] | [next] | [standalone]
| From | "M. Strobel" <sorry_no_mail_here@nowhere.dee> |
|---|---|
| Date | 2012-04-10 00:34 +0200 |
| Message-ID | <9uh6f9FujlU1@mid.uni-berlin.de> |
| In reply to | #5385 |
Am 09.04.2012 21:35, schrieb Mr. B-o-B: > I was curious about peoples thoughts in regards to OOP with PHP. > > Are there pro's/con's of writing OOP code versus procedural/functional coding? > > Strictly speaking for PHP, I do the bulk of my coding as procedural/functional. I > really haven't found any added benefit to going the OOP route. > > Am I missing something, or is it just a different approach to the same problem? > > Thanks! > > Mr. B-o-B The OOA/OOD way, supported by a selective use of UML, offers one complete path from requirements to application architecture to implementation. For the smaller work at hand and a language not complete OO, but with OO extensions, like PHP, you can choose what suits you best. Objects are data plus code. I found it quite handy for objects like users, companies, orders, invoices, etc that correspond to database entities. /Str.
[toc] | [prev] | [next] | [standalone]
| From | Goran <goran@nospam.com> |
|---|---|
| Date | 2012-04-10 10:14 +0200 |
| Message-ID | <jm0q4d$r0f$1@ss408.t-com.hr> |
| In reply to | #5385 |
On 9.4.2012 21:35, Mr. B-o-B wrote: > I was curious about peoples thoughts in regards to OOP with PHP. > > Are there pro's/con's of writing OOP code versus procedural/functional > coding? If you stick with procedural programming you will never get a decent job :D
[toc] | [prev] | [next] | [standalone]
| From | "M. Strobel" <sorry_no_mail_here@nowhere.dee> |
|---|---|
| Date | 2012-04-10 12:06 +0200 |
| Message-ID | <9uif13F97cU1@mid.uni-berlin.de> |
| In reply to | #5398 |
Am 10.04.2012 10:14, schrieb Goran: > On 9.4.2012 21:35, Mr. B-o-B wrote: >> I was curious about peoples thoughts in regards to OOP with PHP. >> >> Are there pro's/con's of writing OOP code versus procedural/functional >> coding? > > If you stick with procedural programming you will never get a decent job :D and even kill your self-fulfillment as programmer. /Str.
[toc] | [prev] | [next] | [standalone]
| From | The Natural Philosopher <tnp@invalid.invalid> |
|---|---|
| Date | 2012-04-10 13:04 +0100 |
| Message-ID | <jm17jg$iq0$1@news.albasani.net> |
| In reply to | #5398 |
Goran wrote: > On 9.4.2012 21:35, Mr. B-o-B wrote: >> I was curious about peoples thoughts in regards to OOP with PHP. >> >> Are there pro's/con's of writing OOP code versus procedural/functional >> coding? > > If you stick with procedural programming you will never get a decent job :D True. Its one of those fashions that everybody has to do, like wearing a suit at a bank used to be. No doubt it will pass in time. -- To people who know nothing, anything is possible. To people who know too much, it is a sad fact that they know how little is really possible - and how hard it is to achieve it.
[toc] | [prev] | [next] | [standalone]
| From | Tim Streater <timstreater@greenbee.net> |
|---|---|
| Date | 2012-04-10 16:07 +0100 |
| Message-ID | <timstreater-7FDE08.16075510042012@news.individual.net> |
| In reply to | #5405 |
In article <jm17jg$iq0$1@news.albasani.net>, The Natural Philosopher <tnp@invalid.invalid> wrote: > Goran wrote: > > On 9.4.2012 21:35, Mr. B-o-B wrote: > >> I was curious about peoples thoughts in regards to OOP with PHP. > >> > >> Are there pro's/con's of writing OOP code versus procedural/functional > >> coding? > > > > If you stick with procedural programming you will never get a decent job :D > > True. Its one of those fashions that everybody has to do, like wearing a > suit at a bank used to be. > > No doubt it will pass in time. OO could be dangerous: <http://www.danielsen.com/jokes/objecttoaster.txt> -- Tim "That excessive bail ought not to be required, nor excessive fines imposed, nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
[toc] | [prev] | [next] | [standalone]
| From | The Natural Philosopher <tnp@invalid.invalid> |
|---|---|
| Date | 2012-04-10 16:28 +0100 |
| Message-ID | <jm1jib$bun$1@news.albasani.net> |
| In reply to | #5413 |
Tim Streater wrote: > In article <jm17jg$iq0$1@news.albasani.net>, > The Natural Philosopher <tnp@invalid.invalid> wrote: > >> Goran wrote: >> > On 9.4.2012 21:35, Mr. B-o-B wrote: >> >> I was curious about peoples thoughts in regards to OOP with PHP. >> >> >> >> Are there pro's/con's of writing OOP code versus procedural/functional >> >> coding? >> > > If you stick with procedural programming you will never get a >> decent job :D >> >> True. Its one of those fashions that everybody has to do, like wearing >> a suit at a bank used to be. >> >> No doubt it will pass in time. > > OO could be dangerous: > > <http://www.danielsen.com/jokes/objecttoaster.txt> > That was exactly the sort of scenario that downed my friends company. Thanks for the laugh. -- To people who know nothing, anything is possible. To people who know too much, it is a sad fact that they know how little is really possible - and how hard it is to achieve it.
[toc] | [prev] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2012-04-10 12:08 -0400 |
| Message-ID | <jm1ltq$e7i$1@dont-email.me> |
| In reply to | #5413 |
On 4/10/2012 11:07 AM, Tim Streater wrote: > In article <jm17jg$iq0$1@news.albasani.net>, > The Natural Philosopher <tnp@invalid.invalid> wrote: > >> Goran wrote: >> > On 9.4.2012 21:35, Mr. B-o-B wrote: >> >> I was curious about peoples thoughts in regards to OOP with PHP. >> >> >> >> Are there pro's/con's of writing OOP code versus procedural/functional >> >> coding? >> > > If you stick with procedural programming you will never get a >> decent job :D >> >> True. Its one of those fashions that everybody has to do, like wearing >> a suit at a bank used to be. >> >> No doubt it will pass in time. > > OO could be dangerous: > > <http://www.danielsen.com/jokes/objecttoaster.txt> > LOL, Beautiful, Tim! -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ==================
[toc] | [prev] | [next] | [standalone]
| From | "M. Strobel" <sorry_no_mail_here@nowhere.dee> |
|---|---|
| Date | 2012-04-10 19:14 +0200 |
| Message-ID | <9uj83vFbd9U1@mid.uni-berlin.de> |
| In reply to | #5413 |
Am 10.04.2012 17:07, schrieb Tim Streater: > In article <jm17jg$iq0$1@news.albasani.net>, > The Natural Philosopher <tnp@invalid.invalid> wrote: > >> Goran wrote: >> > On 9.4.2012 21:35, Mr. B-o-B wrote: >> >> I was curious about peoples thoughts in regards to OOP with PHP. >> >> >> >> Are there pro's/con's of writing OOP code versus procedural/functional >> >> coding? >> > > If you stick with procedural programming you will never get a decent job :D >> >> True. Its one of those fashions that everybody has to do, like wearing a suit at a >> bank used to be. >> >> No doubt it will pass in time. > > OO could be dangerous: > > <http://www.danielsen.com/jokes/objecttoaster.txt> > And Prolog is only good to find new aspects in your family - fathers, mothers, uncles, children. And Lisp is just the best choice to find the greatest common denominator. no links about that, my experience. I guess the list of irrelevant programming examples is ever growing, to infinity. /Str.
[toc] | [prev] | [next] | [standalone]
| From | The Natural Philosopher <tnp@invalid.invalid> |
|---|---|
| Date | 2012-04-10 18:19 +0100 |
| Message-ID | <jm1q2q$qs6$2@news.albasani.net> |
| In reply to | #5431 |
M. Strobel wrote: > Am 10.04.2012 17:07, schrieb Tim Streater: >> In article <jm17jg$iq0$1@news.albasani.net>, >> The Natural Philosopher <tnp@invalid.invalid> wrote: >> >>> Goran wrote: >>>> On 9.4.2012 21:35, Mr. B-o-B wrote: >>>>> I was curious about peoples thoughts in regards to OOP with PHP. >>>>> >>>>> Are there pro's/con's of writing OOP code versus procedural/functional >>>>> coding? >>>>> If you stick with procedural programming you will never get a decent job :D >>> True. Its one of those fashions that everybody has to do, like wearing a suit at a >>> bank used to be. >>> >>> No doubt it will pass in time. >> OO could be dangerous: >> >> <http://www.danielsen.com/jokes/objecttoaster.txt> >> > > And Prolog is only good to find new aspects in your family - fathers, mothers, > uncles, children. > > And Lisp is just the best choice to find the greatest common denominator. > > no links about that, my experience. I guess the list of irrelevant programming > examples is ever growing, to infinity. > Loads of Irrelevant Superfluous Parentheses, isn't it? If you can't code, talk about programming languages and if you can't even do that, design a new one based on some Obscure Academic Principle. > /Str. -- To people who know nothing, anything is possible. To people who know too much, it is a sad fact that they know how little is really possible - and how hard it is to achieve it.
[toc] | [prev] | [next] | [standalone]
| From | Michael Fesser <netizen@gmx.de> |
|---|---|
| Date | 2012-04-10 14:49 +0200 |
| Message-ID | <fj98o7953g5tog42ipm235ovoa4ds9s2m1@mfesser.de> |
| In reply to | #5385 |
.oO(Mr. B-o-B) >I was curious about peoples thoughts in regards to OOP with PHP. > >Are there pro's/con's of writing OOP code versus procedural/functional >coding? > >Strictly speaking for PHP, I do the bulk of my coding as >procedural/functional. I really haven't found any added benefit to going >the OOP route. > >Am I missing something, or is it just a different approach to the same >problem? Besides what the others have written, there are some things that I really like about using OOP in PHP: * comfort With PHPDoc comments and a good IDE (e.g. Eclipse/PDT) you can get many assistance when writing code. You type an object variable, and since the IDE knows from the comments of what class it is, it automatically suggests available method names with their descriptions, parameter lists etc. * security You can define access restrictions on methods and member variables and type hinting on parameter passing, so that PHP can check if a passed object belongs to a particular class or interface. And most important for me: * inheritance/polymorphism You can easily extend the functionality of a class by deriving a child class from it. But you can also still use the child class in a context where an object of the base class is required, without having to change any code. I use this in my form classes for example: For all the basic form controls (input fields, select boxes, password fields, ...) I have my classes. If I should now need a more special control, e.g. a select box with some predefined values, I simply derive a child class, add some other initialization code and that's it. Just a few lines. In every other context, e.g. when creating the form or processing its data, I don't have to change anything, I can use the new form control like any others. Another example: When I call the output methods of my visual objects (all the stuff, that represents something on an HTML page), I just have to make sure the objects are derived from the base class for these visual objects, because then I know that all derived classes will also have a render method and be able to output something. I don't have to know what these objects are and what they represent, I just tell them "render yourself" and that's it. Micha -- http://mfesser.de/blickwinkel
[toc] | [prev] | [next] | [standalone]
| From | "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> |
|---|---|
| Date | 2012-04-10 17:29 +0200 |
| Message-ID | <jm1jl1$ji$1@dont-email.me> |
| In reply to | #5385 |
El 09/04/2012 21:35, Mr. B-o-B escribió/wrote: > I was curious about peoples thoughts in regards to OOP with PHP. > > Are there pro's/con's of writing OOP code versus procedural/functional > coding? > > Strictly speaking for PHP, I do the bulk of my coding as > procedural/functional. I really haven't found any added benefit to going > the OOP route. > > Am I missing something, or is it just a different approach to the same > problem? IMHO, OOP suffers from two problems that aren't actually intrinsic to it: 1. For many people, it's a religion. This leads to endless debates about design patterns and implementation subtleties that replace actual code typing. It also leads to teachers and teaching materials that focus on how utterly complex and philosophical OOP is rather than how useful it is. (There seems to be a endless flow of OOP tutorials out there that explain how to code cats and dogs and, apparently, it requires many lines of code.) 2. Discussions about OOP always assume that there's only one type of application to be written and only one type of team to write it: the mega enterprisey ERP financed by a big-bucks customer maintained by a 20+ team. To make it worse, most of the noise comes from fairly experienced non-PHP programmers who are forced to code in a language they neither understand nor like and get frustrated when they can't make PHP behave like Java. OOP is a tool. It's a darn good tool and it's just one more tool: that says it all. I suffer when I see a thousand lines of getters and setters that actually do nothing and I suffer when I see a shopping cart build on top of 5-level nested arrays. -- -- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain -- Mi sitio sobre programación web: http://borrame.com -- Mi web de humor satinado: http://www.demogracia.com --
[toc] | [prev] | [next] | [standalone]
| From | The Natural Philosopher <tnp@invalid.invalid> |
|---|---|
| Date | 2012-04-10 16:34 +0100 |
| Message-ID | <jm1jtc$cue$1@news.albasani.net> |
| In reply to | #5416 |
Álvaro G. Vicario wrote: > El 09/04/2012 21:35, Mr. B-o-B escribió/wrote: >> I was curious about peoples thoughts in regards to OOP with PHP. >> >> Are there pro's/con's of writing OOP code versus procedural/functional >> coding? >> >> Strictly speaking for PHP, I do the bulk of my coding as >> procedural/functional. I really haven't found any added benefit to going >> the OOP route. >> >> Am I missing something, or is it just a different approach to the same >> problem? > > IMHO, OOP suffers from two problems that aren't actually intrinsic to it: > > 1. For many people, it's a religion. This leads to endless debates about > design patterns and implementation subtleties that replace actual code > typing. It also leads to teachers and teaching materials that focus on > how utterly complex and philosophical OOP is rather than how useful it > is. (There seems to be a endless flow of OOP tutorials out there that > explain how to code cats and dogs and, apparently, it requires many > lines of code.) > > 2. Discussions about OOP always assume that there's only one type of > application to be written and only one type of team to write it: the > mega enterprisey ERP financed by a big-bucks customer maintained by a > 20+ team. > > To make it worse, most of the noise comes from fairly experienced > non-PHP programmers who are forced to code in a language they neither > understand nor like and get frustrated when they can't make PHP behave > like Java. > > OOP is a tool. It's a darn good tool and it's just one more tool: that > says it all. I suffer when I see a thousand lines of getters and setters > that actually do nothing and I suffer when I see a shopping cart build > on top of 5-level nested arrays. > Just try tracing any simple action like pressing a key in a modern OO program. It is horrendous. I like the OO paradigm - its a good tool and I learnt from it. But I don't write for OO languages. I don't need to as I am not coding for mega-enterprises. Sometimes a state machine is a good tool too..just depends what you are trying to do. > -- To people who know nothing, anything is possible. To people who know too much, it is a sad fact that they know how little is really possible - and how hard it is to achieve it.
[toc] | [prev] | [next] | [standalone]
| From | crankypuss <no@email.thanks> |
|---|---|
| Date | 2012-04-11 05:16 -0600 |
| Message-ID | <jm3p6n02qe@news1.newsguy.com> |
| In reply to | #5385 |
On 04/09/2012 01:35 PM, Mr. B-o-B wrote: > I was curious about peoples thoughts in regards to OOP with PHP. > > Are there pro's/con's of writing OOP code versus procedural/functional > coding? > > Strictly speaking for PHP, I do the bulk of my coding as > procedural/functional. I really haven't found any added benefit to going > the OOP route. > > Am I missing something, or is it just a different approach to the same > problem? OOP is basically a good idea carried to an extreme. There is a boatload of value in the concept of inheritance, but that's largely negated by the mechanics of how inheritance is done in OOP languages. Polymorphism is something that's more in the eye of the programmer than in the language, data constructs can be specific or generalized. The idea that making something into an object gives it superior robustness is a joke if you can step back and look at it. I remember writing a Java application and trying to derive an actually useful string class from the garbage they had declared "final" and that was it for me and Java. I cannot begin to count the times when I've had to hoke up an object pointer to use some simple processing method that was part of a C++ class. Of course that's all personal opinion. I avoid all OOP constructs in PHP wherever I can, the more closely I can make it resemble C the easier it will be to convert it when the time comes. There is one exception to that in my code, one of the zip functionalities is only supported through some objects... that stuff is encapsulated in a subroutine. Since I value inheritance I've build myself a layered methodology that lets me override various functions by adding or inserting different layers at runtime. Perhaps the nicest thing about programming is that it puts the lie to religious adherences... as one of my college instructors put it, "if your program works for all cases it is by definition correct".
[toc] | [prev] | [next] | [standalone]
| From | Goran <goran@nospam.com> |
|---|---|
| Date | 2012-04-11 16:25 +0200 |
| Message-ID | <jm448d$rtl$1@ss408.t-com.hr> |
| In reply to | #5456 |
On 11.4.2012 13:16, crankypuss wrote: > I remember writing a Java application and trying to derive an actually > useful string class from the garbage they had declared "final" and that > was it for me and Java. Just for curiosity, which method you tried to override? Somehow i smell a good reason for "final" :)
[toc] | [prev] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2012-04-11 13:06 -0400 |
| Message-ID | <jm4dnm$cj7$1@dont-email.me> |
| In reply to | #5457 |
On 4/11/2012 10:25 AM, Goran wrote: > On 11.4.2012 13:16, crankypuss wrote: >> I remember writing a Java application and trying to derive an actually >> useful string class from the garbage they had declared "final" and that >> was it for me and Java. > > Just for curiosity, which method you tried to override? Somehow i smell > a good reason for "final" :) Actually, I agree with Cranky on this one. I, too, have wanted to override the java String class and been frustrated by its 'final' attribute. I don't see why it couldn't have been created as non-final - and it would have been a lot more usable. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ==================
[toc] | [prev] | [next] | [standalone]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | comp.lang.php
csiph-web