Fwd: Re: [PHP-PEAR] [drift] About function renaming

Chuck Hagenbuch chuck@horde.org
Tue, 20 Feb 2001 15:58:06 -0500


opinions? do we switch things back? should i argue? i don't really care, i just 
wnat it to be consistent, and all factory methods being consistent is better 
than nothing being consistent...

----- Forwarded message from "Stig S. Bakken" <ssb@fast.no> -----
    Date: Mon, 19 Feb 2001 10:21:40 +0100
    From: "Stig S. Bakken" <ssb@fast.no>
Reply-To: "Stig S. Bakken" <ssb@fast.no>
 Subject: Re: [PHP-PEAR] [drift] About function renaming
      To: "Stig S. Bakken" <Stig.Bakken@fast.no>

"Stig S. Bakken" wrote:
>
> Chuck Hagenbuch wrote:
> >
> > Quoting "Stig S. Bakken" <ssb@fast.no>:
> >
> > > There's one problem with this: the DB factory method doesn't know
how to
> > > (and IMHO shouldn't know how to) capitalize the driver name, so I
want
> > > to make an exception for DB, keeping it all lowercase like today.
> > > Nobody should be using the DB backend classes directly anyway
unless
> > > they know what they are doing.
> >
> > If we're going to make an exception, then we should make an
exception for
> > anything that could have a factory method, not just DB. Like the
Mail
> > subclasses. But I wrote the logic for finding the subclass into
Mail::factory
> > (); it's not that complex. Part of the _point_ of a factory method
is that you
> > don't need to know all of the details about the object you're
getting back, so
> > I'd argue that knowing how to find the proper subclass is something
that the
> > factory method could know.
> >
> > And who are we to say what kinds of classes ought to have factory
methods?
> > Exceptions are a slippery slope; once you start making them it
becomes easier
> > and easier to justify more, and harder and harder to keep anything
simple and
> > standard. So I think either we say that subclasses are lowercased,
or we make
> > the factory methods smarter. I vote for the latter.
>
> Some of DB's design (inside my head of course) is that no
modifications
> to the main DB class should be necessary for new backends to be
> implemented.  That means that the knowledge DB has about how to find
the
> proper "subclasses" should dictate the naming of the module files. 
With
> "proper" capitalization, DB's current backends would be named:
>
>   DB_MySQL  DB_OCI8  DB_mSQL  DB_InterBase  DB_ODBC  DB_PostgreSQL
> DB_Sybase
>
> If the DB class is to dictate it has to be all strtolower, all
> strtoupper or ucfirst, to put it in PHP terms.  IMHO, ucfirst is just
> confusing (Msql instead of mSQL?) and strtoupper is "loud", to me
> strtolower is the lesser evil.

On a general note, I think strtolower for all factory-used methods is
ok.

 - Stig

----- End forwarded message -----



-chuck

--
Charles Hagenbuch, <chuck@horde.org>
"We have no fuel on board, plus or minus 8 kilograms." -A NASA scientist