well, two reasons, the practical one: checks for null are annoying, and people tend to lazily forget them.
the more theoretical reason, is that null is not a truly OO concept (at least according to some authors), and you should use a NullObject concept (being of same type as your normal Object expected by the code) instead. In opposite to the NullObject the null misses important semantics about the objects structure. Using null for string initialization is an entry point to bad practices, absolutely 'bad' are following practices: putting null in lists/maps transporting null over network (rmi,corba,soap etc) putting null beans in scopes (not sure this works, but should never bin tried :-)) returning null from functions instead of more meaningfull reply: For example getUser(String userName) should throw a NotSuchUserException if there is no corresponding User object instead of returning null. There are very few scenarios (mostly high performance, where null is actually expected - i.e. caches) where this rule can be broken. I think you can find more examples in a good pattern book :-) HTH Leon On 3/16/06, manny Calaverra <[EMAIL PROTECTED]> wrote: > hi Leon, > > is this rule because of the NullPointerException you get when, for example > you check the Strings ".length()" or is there (also) another reason for this > practice? > > thanks in advance > Julian > > > --- Ursprüngliche Nachricht --- > > Von: "Leon Rosenberg" <[EMAIL PROTECTED]> > > An: "Struts Users Mailing List" <user@struts.apache.org> > > Betreff: Re: ActionForm Stringvariables > > Datum: Thu, 16 Mar 2006 11:06:50 +0100 > > > > 1. The general rule is: never use null. > > 2. The specific rule for your application must be given by your > > application, but in doubt the general rule applies. > > > > regards > > leon > > > > On 3/16/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > Hi there, > > > > > > I'm a newbie to struts and I have a question concerning ActionForms. > > > What's more clever: to initialize the String-parameters with "null" or > > with > > > "" (empty strings)? > > > > > > thx & ciao 4 now > > > Julian > > > > > > > > > -- > > > "Feel free" mit GMX FreeMail! > > > Monat für Monat 10 FreeSMS inklusive! http://www.gmx.net > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > -- > Echte DSL-Flatrate dauerhaft für 0,- Euro*! > "Feel free" mit GMX DSL! http://www.gmx.net/de/go/dsl > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]