Re: [PHP-PEAR] [drift] About function renaming
[email protected] ("Stig S. Bakken")
| Newsgroups | php.pear |
|---|---|
| Organization | Fast Search & Transfer |
| Message-ID | <[email protected]> |
Chuck Hagenbuch wrote: > > Quoting "Stig S. Bakken" <[email protected]>: > > > 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. - Stig