Re: [PEPr] Comment on Database::Mongo

From: Date: Sat, 21 Mar 2009 15:49:26 +0000
Subject: Re: [PEPr] Comment on Database::Mongo
References: 1 2  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-51645@lists.php.net to get a copy of this message
On Thu, Mar 19, 2009 at 5:17 PM, Kristina Chodorow <kristina@10gen.com> wrote: > > Wow, thank you for all your feedback!  I'm working on all the changes and > refactoring, I'll have them up ASAP. > > What does DI stand for? Dependency Injection. > I am using the mongo.* ini variables for default hostname and port, were > there other things you thought I should use them for?  I tried to mirror > the variables MySQL uses, as far as was applicable, to minimize confusion.. No, that's great. I just saw the global constants when I scanned through your github repo. > I'll start at 0.1.0.  Not sure why I started at 0.8.0, I guess because > that's where MongoDB is right now. Ok, sweet! > Why Java is needed: Java is used to parse/execute JavaScript code. > MongoDB allows you to pass it strings of JavaScript for it to evaluate so > you can combine multiple database commands into a function to avoid making > multiple trips to the database (I guess our version of stored procedures or > user defined functions... sort of).  You can read more about it at > http://www.mongodb.org/display/DOCS/Server-side+Code+Execution > and > http://www.mongodb.org/display/DOCS/Server-Side+Processing. Thanks! :) Btw -- I saw you started refactoring your code, a few additions: 1) In Mongo.php you always use _connectUtil, when instead you should use $this->_connectUtil 2) Use protected and not private (makes overriding/extending the class easier) 3) Put the require_once first and only include what is needed -- e.g. do the include where the dependency is needed. 4) Class naming is still off, e.g. MongoAuth > Mongo_Auth (Mongo/Auth.php), MongoAdmin > Mongo_Admin (Mongo/Admin.php) 5) Your exception needs to extend PEAR_Exception 6) I see you are using 1, 2, etc. for exception codes, I'd propose this instead: class Mongo ... { const ERR_CONNECTION = 'MONGO1'; const ERR_CURSOR = 'MONGO2'; } ... so in the end, this would allow me to do this: try { $mongo = ... ... } catch (Mongo_Exception $e) { if ($e->getCode() == Mongo::ERR_CONNECTION) { // do something else } } Cheerio! Till

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