Re: Re: Validation class comments

From: Date: Tue, 23 Apr 2002 19:39:09 +0000
Subject: Re: Re: Validation class comments
References: 1 2 3 4  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-6603@lists.php.net to get a copy of this message
Hello, On 05/29/2002 07:07 AM, Peter Bowyer wrote:
At 19:57 28/05/02 -0300, Manuel Lemos wrote:
Another thing, if you do not minimize class dependencies you may be turning your applications into bloatware because you may be including single classes that have chained dependencies on many others that will be loaded even if you do not used the chained classes functions at all. 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. 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.
Then write smaller classes :-) Rather than putting function-libraries-wrapped-in-classes into PEAR why not make much smaller classes, so reducing the overhead?
Because the built-in validation types just contain 2 lines and it does not pay to move them to separate classes.
It is often better to duplicate small pieces of code, like you want to 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.
I belive that a truly modular setup like Vincent Oostindie proposed a while back (much smaller classes) may be beneficial. Then you are not loading tons of unwanted code, but only the portion that you really require. Wouldn't this solve the problem?
You should learn how Zend compiler and PHP code loading and execution works before making such guesses. Zend compiler separates compilations in 3 parts: global code, global functions and classes. If you move code from a class to create another with separated validation code, eventually you force a separate compilation process for that class with all the execution and memory overhead that incurs. This is why I say it does not pay to take very simple validation types into separate classes that you will have to load frequently. -- Regards, Manuel Lemos

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