Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Whether to return String "True" or "False" instead of 1 or 0

Re: Whether to return String "True" or "False" instead of 1 or 0

From: Brian Peasland <dba_at_nospam.peasland.net>
Date: Thu, 16 Aug 2007 14:14:57 -0500
Message-ID: <46c49622$0$22967$88260bb3@free.teranews.com>


CrazyKarma wrote:
> One of the developers had written a function such that it returns a
> string value as either "True" or "False", which was again used in a
> sql context with a decode statement wrapped around it to do something
> else.
>
>
> During code review, I called it out and said that its better to have
> that return a int as 1 or 0, so that its flexiable in future to return
> more values and also put to a comment to say what each value stands
> for.
>
> Developer disagreed saying that his method is more readable and either
> way we will have to change the code if we have to make it return
> different values in future.
>
> I agree that the code is more readable but extent of change presuming
> that the data fetched may be different in future is less with my
> change.
>
> also believe string equality checks is exposed to case sensitivity
> issues.
>
> what do you all think?
>

IMO, the data should represent the attribute. Is the attribute a true or false value? If so, the data should represent that. What does 0 or 1 mean? If you truly mean true and false, then using 0 or 1 could be misleading in certain contexts, i.e. implying that 1 > 0 when we know that TRUE is not greater than FALSE.

HTH,
Brian

-- 
===================================================================

Brian Peasland
dba_at_nospam.peasland.net
http://www.peasland.net

Remove the "nospam." from the email address to email me.


"I can give it to you cheap, quick, and good.
Now pick two out of the three" - Unknown

-- 
Posted via a free Usenet account from http://www.teranews.com
Received on Thu Aug 16 2007 - 14:14:57 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US