Re: CS discussion

From: Date: Tue, 15 Jul 2003 20:53:14 +0000
Subject: Re: CS discussion
References: 1 2  Groups: php.pear.qa 
Request: Send a blank email to pear-qa+get-64@lists.php.net to get a copy of this message
On Tue, Jul 15, 2003 at 10:18:47PM +0200, Lukas Smith wrote: > > If the first thing you're looking for is open() / close(), then that's > > what they should be named (especially if they're accurate names). > > > > I understand that you want to use a generic name for containers, but > > think of a Cache container. It's more natural to open or close a > > cache, not connect and disconnect to it. But when we're talking about > > a database connection, the connect() / disconnect() pair is more > > obvious. > > The question is just if we can educate our users to think different (tm) > :-) Fun aside (I get your joke <g>), I'm not sure it's really education. When a user chooses to use a new package / class, they're going to have to look at it's API. For the most part, they're not going to be blindly guessing. Sure, it's a nice thought to make the names predictable, when there are multiple (good) possibilities, they're just going to have to look it up. If we really want to add something to the Coding Standards about this, it should be something like: Use thoughtful, consistent and obvious method names when designing your package's API. When in doubt, refer to a similar PEAR package's API for inspiration. That's all we should really need. > Once they do I think there is a benefit. However lets not shot the > entire idea down based on that single proposal. I'm not, but I do think the idea is too strict in general. > For example currently in LiveUser the factory method is called create() > and I hear some packages use getInstanceOf() for the singleton. create() is ambiguous. getInstanceOf() is accurate but verbose. factory() / singleton() presuppose knowledge of the established pattern names themselves. -- Jon Parise (jon@php.net) :: The PHP Project (http://www.php.net/)

« previous php.pear.qa (#64) next »