Re: [drift] About function renaming
| From: | Stig S. Bakken | Date: | Mon, 19 Feb 2001 09:21:40 +0000 |
| Subject: | Re: [drift] About function renaming | ||
| References: | 1 2 | Groups: | php.pear |
| Request: | Send a blank email to php-pear+get-1377@lists.php.net to get a copy of this message | ||
"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