Saturday, June 13, 2009

Design patterns

Safe Getters and Setters
-domain objects returning collection objects in getter should check for null
and return EMPTY_COLLECTION instead of null collection
-domain objects returning string objects in getter should check for null and
return empty string instead of null

Assert methods to validate method arguments
-call assert methods to check for null arguments instead of checking objects for null and throwing an IllegalArgumentException

-in graph of objects add getter methods to link child objects to parent objects

Null object Design pattern
-to avoid checking for null across the whole application. centralize the null checks within domain object, service object getters

No comments:

Post a Comment