Wednesday, March 16, 2005

Yes or No? Is there a best practice when it comes to cftag attributes.

Is there a best practice for choosing between "yes/no" vs. "true/false" vs. "1/0" (haha, that last one is undefined)?

Of course, there may be some constraints imposed by external technologies like your database.

I've noticed that in cf tags you will sometimes see thisAttribute = "yes/no" or thisAttribute = "true/false".

Is there a reason why one would be used over the other? I'm not even sure why the choice exists.

It looks like the latest documentation is going with the yes/no approach for tag attributes in general. There are still some consistency problems with some of the functions. For example, xmlNew() uses true/false to indicate case sensitivity, whereas xmlParse() uses yes/no for the same thing.

I think I'm leaning toward the yes/no approach. It's still clear, it's a little shorter, and it seems like it is used most in the cf docs. I'll probably tend to still use the 1/0 approach for anything relating to sql or web services. It just seems to work more reliably that way.

Any thoughts?

1 comment:

  1. I used to completely agree -- but lately, I've actually gone the other way. I've even edited the VTM files for HomeSite+ to use true/false where they've been set to yes/no, and CVEclipse already uses true/false.

    The main reason I've switched is because CF is the only language I use where yes/no is used -- and I really like the idea of spending fewer "brain cycles" interpreting code. Since CF doesn't care, why not let my brain use terminology that's common to all the languages I use?

    Obviously, this doesn't actually matter -- personal preference is the key here; whatever works for you, well, works for you!

    ReplyDelete