Re: [PEPr] Comment on Database::Mongo
| From: | Kristina Chodorow | Date: | Mon, 23 Mar 2009 16:37:51 +0000 |
| Subject: | Re: [PEPr] Comment on Database::Mongo | ||
| References: | 1 2 3 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-51651@lists.php.net to get a copy of this message | ||
I fixed all the points you mentioned except for 4:
4) Class naming is still off, e.g. MongoAuth > Mongo_Auth
Unfortunately, I don't think I can conform to this naming standard. I
already have some users, and I don't want to suddenly switch all the class
names out from under them.
Hopefully this isn't a deal breaker!
> 5) Your exception needs to extend PEAR_Exception
I did this, but I am a bit worried about people not having PEAR installed.
Is PEAR/Exception.php installed automatically with PHP? If not, I don't
think I should depend on it. People could just download the .tgz.
Also, I've had my proposal up for a week now, and the instructions says I
should call for votes if it seems like enough people would vote for it. I'm
not clear though, if there are enough, so if people could let me know
if/which way they would vote, I'd really appreciate it.
Thanks!
Kristina
On Sat, Mar 21, 2009 at 11:49 AM, till <klimpong@gmail.com> wrote:
> 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
>
>
>