Re: Re: Validation class comments

From: Date: Tue, 23 Apr 2002 20:01:18 +0000
Subject: Re: Re: Validation class comments
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-6608@lists.php.net to get a copy of this message
Hello, On 05/29/2002 04:48 AM, Pierre-Alain Joye wrote:
That is all nice and dandy in theory but in practice that is not a good idea in PHP.
I am an idealist ;).
You are a the theory guy! :-)
People always complained about Microsoft bloatware, but in part that is a result of the fact that applications are written in C++. The problem is not in the language, but in the implicit dependencies of classes that require each other. KDE applications also have the same problem precisely because they are written in C++.
I cannot call that a problem. It's just a way they decide to go and make their life easier.
Easier? When simple programs exhaust your computer memory by loading much more code than it is necessary, what you think is making your life easier is indead an headache.
The problem of C++ is that when you need a function of a certain class, you need to include the code of the whole class in the program, even if you just need 1% of the whole code of the class. The class gets wholy loaded in memory taking much RAM and much space in disk.
That's true for a compiled langage (note it's possible to minimize this effect). Disk spaces cost less for me than times :).
You must not forget that PEAR is just not for you. Whatever is your budget for hardware may be something out of reach for users that can't invest that much on hardware. Anyway, RAM abuses will hit you as well when you tro scale your software to attend the needs of a busy site when you need to fork much more processes to keep up with the demand of HTTP requests.
Java has less of that problem because it supports late bindings, meaning, classes are only loaded in memory if and when needed at runtime.
Same on php, check DB, Autoload or simply the first shot of ::Validate
Dynamic loading as a very high an execution overhead price because it requires that Zend compiler goes through the included code again. That is a very high price to load too small components, even more when they are needed frequently.
Many PHP class libraries like a lot that exist in PEAR has the same viral interdependency. Maybe you have not noticed this, but I am afraid that soon or later PEAR classes will be associated with bloatware precisely due to excessive interdependency.
IMHO, I consider there is too much code duplication. As far I decide to use differents modules, I do not want to make changes to any little kind of functions just because they duplicate functionnalities around all the modules.
Most types of validation only require as little as 2 lines of code. It does not make much sense to modularize such a small amount of code.
It is often better to duplicate small pieces of code,
I m an extremist :). Duplicating code is ganz verboten ;). Very small pieces, ok. Anything else do not have to be duplicate. Duplicating codes is the begin of the nigthmare.
I don't think that it is that black or white. It depends. Duplicating small amounts of code is no big deal.
do with validation classes, into a single class that uses that code integratedly instead of using separate modulare validation classes as you suggest. This is what the forms validation and generation class does.
So why a oo implementation ? Use functions :).
I do. My forms validation class has built-in a set of type of validation that are most common and are very trivial. Additional not so common types of validation can be specified with external functions. -- Regards, Manuel Lemos

« previous php.pear.dev (#6608) next »