Hello to downloaders of this class,
I've written this class and put it available for downloads from
my web site (www.fr-webdev.net) and from PHP Classes (www.phpclasses.org).
I'm not and expert in PHP and I'm glad to see that my rough work have been
properly rewritten by Yiannis VAVOURANAKIS for PHP4 and PHP5 and I would
thanks him for his interest in this class and for his important work about it.
The classes provided :
- The original class is named : class.biometrics.php (version 1.0)
- The rewriting for PHP4 is named : class.biometrics.php4.php (version 1.1)
- The rewriting for PHP5 is named : class.biometrics.php5.php (version 1.2)
You can find below all the improvements he have provided for this class.
Once again, thanks to him.
Pierre FAUQUE.
26/01/2008, 20:38
----------------------------
From: "Yiannis Vavouranakis" <yiannis@vavouranakis.gr>
To: "Pierre FAUQUE" <pierre@fauque.net>
Subject: RE: Signalisation d'un bug (Classe Biometrics v-1.0)
Date: Sat, 26 Jan 2008 02:47:56 +0200
Hello.
After a long time (3 months) I've finally sat down to clear up the code in
the php5 version of cbiometrics. I'm sending over a zip file, containing
quite a few things. Make sure you read my comments in the demos, the French
one needs proof-reading.
A small list of what I did:
a) Changed the constructor so that it takes an array as argument
b) Removed all the calculated variables and used the corresponding methods
in the demos
c) Changed all the short tags into long tags.
d) Changed the way internationalization works. Now you only need to
translate a file, and simply include it along side with the main class
file (see the demo)
e) Altered the functions that return a textual representation of the data
(t_sex, t_work, t_bmistatus). The original class variables have been either
deleted or moved as variables local to the methods. Moreover, in the
methods, I've made sure that something is always returned, even if the user
doesn't include() a language file.
f) Added accessor functions, to have a more object-oriented appearance
(actually, this is necessary in php5, where I've declared all members as
protected or private).
I tested the class with both demos under apache 2.2 and php5.0.27 (but I
tested both the php4 and the php5 version). They seem to work ok.
Now, regarding your reply on my comments, I have to say the following:
a) Instead of using explicit variables for the data in the constructor, it's
easier to use an array and search for the relevant keys.
b) I know it's a pain to write something like $_POST['myVariable'] instead
of just $myVariable, but trust me, it's a lot safer - besides, PHP
developers actually advise that you turn register_globals off...
c) The extensive use of variables makes use of extra memory, which is a very
limited resource in php scripts (8Mb or less is the default). Moreover, the
way you have it (with variables), you are forcing the server to calculate
everything, regardless of whether it is needed by the calling script or not.
So, it may actually be better both memory-wise and in terms of number of
actions, if you go with the methods and not the variables. Oh, and an extra
thing: This class could easily be used in a larger project, where the
instance would have to be serialized and deserialized. With the variables
method, the resulting serialized object would be substantially larger, as
all the calculated information would be serialized. However, with the
methods method (:-)), you only serialize the initial data (age, weight, etc)
and so the serialized object is quite smaller.
d) An extra thing I forgot to mention is that you used short tags (<? and
?>) instead of <?php and ?>. Although it is still legal to do so, the
default in PHP is not to accept short tags anymore. So I've also changed
that in the files I'm sending over.
Regards,
Yiannis
|