Re: Re: Validation class comments

From: Date: Tue, 28 May 2002 22:57:43 +0000
Subject: Re: Re: Validation class comments
References: 1 2 3  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-6553@lists.php.net to get a copy of this message
Hello, On 05/28/2002 02:44 PM, Pierre-Alain Joye wrote:
Before you re-invent the wheel, this class does what you want and more.
We do not re-invent the wheel, I never see a data validation lib, but only basic form validation with classic data type. The goals of this kind of lib are more to provide a usefull tool to validate any data from any source (forms, soap, csv files). That may be included any encoding for string data, any date format, user number (incl. localisation), etc...
I don't think it is a good idea to create more and more classes to do simple things. In practice that leads serious penalties, that you do not seem to be aware, either in memory consuption or script compilation and loading speed. 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.
http://www.phpclasses.org/formsgeneration
This class does not match the goals defined here. A data validation class must be able to be called from any objects, a modular plugin architecture ( localisation is a must if we want to valid user input data or proprietary export data ).
That is all nice and dandy in theory but in practice that is not a good idea in PHP. 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++. 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. Java has less of that problem because it supports late bindings, meaning, classes are only loaded in memory if and when needed at runtime. 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.
Your mail validation class should be a part of the project, but, sorry, I personnaly do not consider formsgeneration as modular ( I especially like the addInput method ;)) ).
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. -- Regards, Manuel Lemos

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