Best way to integrate classes

This is a discussion on Best way to integrate classes within the PHP Language forums, part of the PHP Programming Forums category; Nikolai Chuvakhin wrote: > "Swartz" <swartz@inbox.ru> wrote in message > news:<104khdbgrafe251@corp....


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #11 (permalink)  
Old 03-08-2004
Bruno Desthuilliers
 
Posts: n/a
Default Re: Best way to integrate classes

Nikolai Chuvakhin wrote:
> "Swartz" <swartz@inbox.ru> wrote in message
> news:<104khdbgrafe251@corp.supernews.com>...
>
>>I'm working here on a small project of mine. I'm not new to programming, but
>>I'm new to PHP. You have to understand that I'm coming from C++, OOP world,
>>so my code might seems a little too "object"-ified.

>
> Actually, it doesn't seem "a little too objectified"; it seems
> unnecessarily objectified. You are creating lots of overhead
> here...
>
>>What is the best approach to integrate the two classes?

>
> The best approach is not to have classes at all, unless you
> need them.
>
>>How would you do it?

>
> By writing standalone functions: login(), logout(), etc. Ask
> yourself a simple question: will you ever have more than one
> instance of your Session class running? Most likely, the answer
> to that question is no, so you will do just fine with standalone
> functions; they will get the job done and won't create any
> unnecessary overhead...


All your rant against OO could be justified if PHP had any other support
for modularity. Since this is not the case, and there's no way to have
functions or vars existing on a 'module' scope only, the only way to
write clean PHP code is to use OO.

The "unnecessary overhead" is the price to pay to have clean, modular
code with lo coupling, and as such is *never* "unnecessary" except
perhaps for the most basic, throw-away scripts.


Bruno

Reply With Quote
  #12 (permalink)  
Old 03-08-2004
Tony Marston
 
Posts: n/a
Default Re: Best way to integrate classes


"Bruno Desthuilliers" <bdesth.quelquechose@free.quelquepart.fr> wrote in
message news:404ba4bc$0$305$636a15ce@news.free.fr...
> Nikolai Chuvakhin wrote:
> > "Swartz" <swartz@inbox.ru> wrote in message
> > news:<104khdbgrafe251@corp.supernews.com>...
> >
> >>I'm working here on a small project of mine. I'm not new to programming,

but
> >>I'm new to PHP. You have to understand that I'm coming from C++, OOP

world,
> >>so my code might seems a little too "object"-ified.

> >
> > Actually, it doesn't seem "a little too objectified"; it seems
> > unnecessarily objectified. You are creating lots of overhead
> > here...
> >
> >>What is the best approach to integrate the two classes?

> >
> > The best approach is not to have classes at all, unless you
> > need them.
> >
> >>How would you do it?

> >
> > By writing standalone functions: login(), logout(), etc. Ask
> > yourself a simple question: will you ever have more than one
> > instance of your Session class running? Most likely, the answer
> > to that question is no, so you will do just fine with standalone
> > functions; they will get the job done and won't create any
> > unnecessary overhead...

>
> All your rant against OO could be justified if PHP had any other support
> for modularity. Since this is not the case, and there's no way to have
> functions or vars existing on a 'module' scope only, the only way to
> write clean PHP code is to use OO.


What is your definition of 'clean' code. It is possible to write beautiful
code without using OO, just as it is possible to write crap code with OO.
Using one technique or the other does not guarantee that your code will be
either excellent or excrement - it is not the technique, it is the
technician.

--
Tony Marston

http://www.tonymarston.net



Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 07:22 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0