need a standard for contrib node build_mode constants

View: New views
2 Messages — Rating Filter:   Alert me  
< Prev | 1 - 2 | Next >

Re: need a standard for contrib node build_mode constants

by Chris Johnson-21 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, May 21, 2009 at 2:09 PM, Jeff Eaton <jeff@...> wrote:

> On May 21, 2009, at 11:50 AM, Chris Johnson wrote:
>
>> After all, we wouldn't want developers to have actually document
>> anything they write.  ;-)
>
> Well... documentation is needed in either case. But with ints, collisions
> are absolutely inevitable. I ran into this with VotingAPI early on -- I had
> a const for 'vote_type', and it had 3 values out of the box. Pretty quickly,
> two other modules both defined fourth value types. suddenly, those modules
> couldn't co-exist with each other.
>
> There's nothing in *my* documentation that could have solved that, other
> than a pointer to a wiki page where everyone claimed ints.


Thanks for the clear example, Jeff.  It makes a huge difference.

If developers of other modules can arbitrarily define new values your
module has to work with, collisions are inevitable, whether integer or
strings.  Strings do enjoy some advantages, including being easier to
grep for.

P.S. Of course, *user* visible constants should be strings.  I always
thought we were talking about developer-only constants here.

Re: need a standard for contrib node build_mode constants

by Earnie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Quoting Chris Johnson <cxjohnson@...>:

>
> P.S. Of course, *user* visible constants should be strings.  I always
> thought we were talking about developer-only constants here.
>

Which must be translated somehow for ease of use by the developer to  
strings.  I.E. in PHP
define ('DEVELOPER_ONLY_CONSTANTS', 1);

--
Earnie
-- http://r-feed.com/           -- http://for-my-kids.com/
-- http://www.4offer.biz/       -- http://give-me-an-offer.com/


< Prev | 1 - 2 | Next >