This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
I have a Java class that models a business domain object. This business domain object has a number of fields that are represented as String-valued data members in the corresponding class. Some of those String-valued fields are not present in some object instances.
Is it better to model such a non-existent (or non-available) field as having an empty String value ("") or should I set it to null?
I've been thinking of this issue in reference to Item #27 from "Effective Java" where Bloch correctly recommends that empty Collections should be returned instead of returning null.
I am just wondering whether the same recommendation should be applicable for simple object types such a String-valued data member.
Would love to hear the thoughts of the more enlightened and experienced minds on JavaRanch...