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

Reply via email to