[seam-dev] Seam 2.1.1.CR2

Gavin King gavin at hibernate.org
Thu Dec 4 14:00:55 EST 2008


You can make the exact same argument about *any* type. The point of
*any* type is to restrict the possible set of values.

Unfortunately, prohibiting null everywhere turns out to be a major
PITA in practice.

On Thu, Dec 4, 2008 at 12:43 PM, Francisco Jose Peredo
<franciscoperedo at tabasco.gob.mx> wrote:

> Yes, but I have always felt uneasy about a null boolean thing... the
> point of boolean is to restrict the possible outcomes of something to
> "true" or "false", but with a nullable boolean we now have 3 possible
> outcomes "true", "false" and "undefined"... and the problem is that
> "undefined" is also "typeless" and therefore bug prone, the code:
>
> if(isUserInRole("administrator)){
> //do something
> }
> else {
> //do something else
> }
>
> looks like something perfectly valid, but it turns out it can crash
> because isUserInRole can return null.
>
> I mean I can understand it for MailComponent.getBoolean,  and
> org.jboss.seam.ui.util.JSF.getBooleanValue, but I don't like it for
> org.jboss.seam.ui.graphicImage.Image.isRatio or
> org.jboss.seam.web.IsUserInRole.isUserInRole.
>
> Wouldn't it be better to use an Enum if there are 3 or more possible
> outcomes?
>
> Regards,
> Francisco
>>
>>>
>>>
>>> Regards,
>>>
>>> Francisco
>>>
>
> _______________________________________________
> seam-dev mailing list
> seam-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/seam-dev
>



-- 
Gavin King
gavin.king at gmail.com
http://in.relation.to/Bloggers/Gavin
http://hibernate.org
http://seamframework.org



More information about the seam-dev mailing list