Re: [PEPr] Call for votes on Encryption::Crypt_RSA

From: Date: Fri, 15 Apr 2005 14:11:48 +0000
Subject: Re: [PEPr] Call for votes on Encryption::Crypt_RSA
References: 1 2 3  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-37253@lists.php.net to get a copy of this message
New vesrion of Crypt_RSA package is available at http://chat.finalcombat.com/valyala/big_int/Crypt_RSA-1.0.0RC4.tgz I did most of Philippe's proposes: - class/directory structure now is PEAR-compliant - removed debug functions from bottom of BCMath wrapper file - removed all calls of exit() function. It mostly replaced by PEAR::raiseError() calls - $wrapper_name now is optional parameter. System tries to load the best abailable wrapper, if its name is omitted. I didn't implement &factory() method. I think, it is completely unnesessary in Crypt_RSA* classes. Why don't use constructors instead? Compare: $rsa = &new Crypt_RSA($params, $wrapperName); // constructor usage $rsa = &Crypt_RSA::factory($params, $wrapperName); // factory() usage Can anybody show me any profit of second line? Philippe Jausions wrote: > That allows you to return a PEAR_Error object if no wrapper class or > extension can be found. Ok, it seems as good reason. But again, compare that methods: // constructor usage $rsa = &new Crypt_RSA; if ($rsa->isError()) { $err = $rsa->getLastError(); echo $err->getMessage(); } // factory() usage $rsa = &Crypt_RSA::factory(); if (PEAR::isError($rsa)) { echo $err->getMessage(); } Is that ritorical question: what purpose of constructors, when factory() method usage? Again, if I'll implement factory() method, I have to duplicate it in three classes: Crypt_RSA, Crypt_RSA_Key, Crypt_RSA_KeyPair. Now all of these classes uses one codebase, placed in Crypt_RSA_MathLoader class, to load math wrapper. Any suggestions?

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