This is a discussion on Re: What is/is not considered to be good OO programming within the PHP Language forums, part of the PHP Programming Forums category; In article <7588a50f.0308070345.708bb31d@posting.google.com >, Tony Marston wrote: > On my website I have an ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
In article <7588a50f.0308070345.708bb31d@posting.google.com >, Tony Marston wrote:
> On my website I have an article > http://www.tonymarston.net/php-mysql...seobjects.html which > describes an abstract class I have written to control all access to > my databases. Someone who is supposed to be a respected member of > the PHP community has informed me that my class breaks the rules of > OO programming and is therefore unworthy of serious consideration. > he considers [the code to be ] related to formatting rather than the > data itself, and as such is *bad* programming. Everyone thinks they know what correct OO is, unfortunately I am the only one that truly knows it. So here is the correct response: Gimme a break. There is _nothing_ in OO which says that you should not mix presentation code with logic code. OO deals with encapsulation and dependencies, not implementation. As long concerns are separated "well enough", there is no reason to worry. Otoh, there is general consensus regarding GUI-apps which says you should not mix presentation with logic. But that is more like common knowledge than OO. > 2) Despite me asking him what he considers to be the *right* way of > doing things he has failed to respond, probably because he doesn't > know the answer. Probably. > 4) The language allows me to do it, therefore it cannot be wrong. Yup, otherwise you'd get a syntax error... > 5) It is simple and it works, therefore it cannot be all that bad. Yes, that is the single most important point to make: KISS -- keep it simple, stupid. Anything else will just make it a lot harder to keep up when the system demands (inevitable) change. > Do you people out there in PHP-land have any opinions on this matter? > Is this critocism justified or not? I think the OO features in PHP3/4 sucks. I mostly use PHPs object as simple wrappers for variables (structs) and keep 95% of all programming functional. |
|
|||
|
Andy Jeffries wrote:
> On Thu, 07 Aug 2003 12:16:55 +0000, Martin Wickman wrote: > >>>4) The language allows me to do it, therefore it cannot be wrong. >> >>Yup, otherwise you'd get a syntax error... > > > I disagree, something can be "wrong" as in an ugly way of doing something > but by syntactically correct. > > However, I agree there is nothing wrong with what he is doing. > If we're talking about doing things wrong from an OOP point of view, there's a shitload of things you can do wrong. This doesn't mean the same thing is wrong from a PHP point of view, since PHP is not truly OO. |