You are here: Re: Zip some folders and send by email « PHP Programming Language « IT news, forums, messages
Re: Zip some folders and send by email

Posted by Rik on 09/28/69 11:52

whosaid@what.net wrote:
> In article <ca40b2dtjr2l0cd0e2lcpvmshpu4mq8h9o@4ax.com>,
> timr@probo.com says...
>> nark <nark.l@home.home.com> wrote:
>>> Please forgive a silly question but can you tell me why you made it
>>> a "class" rather than a simple set of functions?
>>
>> It's fascinating that you would ask this question, and I suspect a
>> PHP newsgroup is the only one in which the value of encapsulation
>> would be questioned.
>>
>> By defining a class, he is adding only one new name to the namespace,
>> instead of a whole set of names that might conflict with functions I
>> already have. In addition, it allows him to hide whatever state he
>> might need in the class object, instead of again polluting the
>> namespace with globals.
>>
>> I know the PHP philosophy is to plop 100 functions into the global
>> namespace where one class name would do, but I suspect PHP programs
>> would be easier to read and maintain if the library were reorganized
>> as classes instead.
> Totally the reverse.
>
> By wrapping it in a class he has made the code unnecessarily complex
> and obtuse to read making understanding of the function difficult
> and the code therefore harder to read and maintain.

In this particular case, it might. But normally I like classes just for that
reason: avoid cluttering of variables, huge if..else.. statements or
switches. Also, scalability comes into play. It might be a simple script
now, but it might grow, which is easier done in OO in my opinion, because
everything has got it's own scope. That also means it almost certainly won't
interfere with already existing code in a project where you want to make us
of the class, which is often the case with procedural programming.

A good constructed class also makes it more clear to me personnaly what's
going on. I can follow code to different methods with ease, which can't
always be said for looking for the next }.

> The use of classes for small amounts of code such as used by PHP
> programmers writing what are not much more than a simple series of
> scripts is plain stupid and says more about the ego of the programmer
> than anything else.

I wouldn't know what the hell this has to do with ego. You don't pretend
anything by making it a class.

> Anything that actually requires classes should bedone in a real
> reliable language not a buggy script language like PHP.

Nothing _requires_ classes. Nothing _requires_ procedural programming. One
choice might serve the purpose (a lot) better then the other, but it's never
exclusive. The only time only one choice can be made is when it's required
by the desired language.

Grtz,
--
Rik Wasmus

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация