I would agree with Chris.  If someone asked you to describe what you are
trying to accomplish, you'd probably say something like:

"Well, I want to get the form comments.  If they're null, I want to
default to an empty string"

And

> String formcomments = attr.getFormComments();
> if (formcommets == null)
>      formcomments = "";

pretty much says it all.

Rowland

> My preference always goes to the easiest to read...I would write:
>
> String formcomments = attr.getFormComments();
> if (formcommets == null)
>      formcomments = "";
>
> IMO, it is more obvious that the result (formcomments) will be assigned
> the value of attr.getFormComments(), unless the special case (null)
> is encountered.
>
>
>
> C
>
>
> disclaimer: This advice is worth exactly what you paid for it...maybe
> less.
>
>
> Tony Spencer wrote:
>> Which of these examples is better practice or does not not really
>> matter?
>>
>> Example 1:
>>
>> String formcomments = attr.getFormComments();
>> formcomments = (formcomments == null) ? "" : formcomments;
>>
>>
>> Example 2:
>> String formcomments = (attr.getFormComments()== null) ? "" :
>> attr.getFormComments();
>
>
> --
> -------------------------------------------------------------------------
> Chris Merrill                  |  http://www.webperformanceinc.com
> Web Performance Inc.           |  http://www.webperformancemonitoring.net
>
> Website Load Testing, Stress Testing, and Performance Monitoring Software
> -------------------------------------------------------------------------
>
>
> _______________________________________________
> Juglist mailing list
> [EMAIL PROTECTED]
> http://trijug.org/mailman/listinfo/juglist_trijug.org
>


_______________________________________________
Juglist mailing list
[EMAIL PROTECTED]
http://trijug.org/mailman/listinfo/juglist_trijug.org

Reply via email to