Design paterns for null arguments 2004-05-28 - By Ben Hill
Back On Fri, 2004-05-28 at 09:56, Sandeep Kachalia wrote: > Thanks Ben, > I wanted to open APIs for my client. The API users may pass null > values as arguments.
Why?
> I have n number of parameters against I need to do null verification. > Can we apply some pattern here through which we check the nullability > and give customerized messages to user.
If you get hold of the Core J2EE patterns book, there is some information on Validation. Or you could Google for "form validation". You might not have a form to validate - more a collection of attributes, but it's the same principal.
This could boil down to a method such as:
public boolean isNull(Object obj) { return (obj == null) ? true : false; }
Oh, and the "myFunction" *method* name is pretty horrible! ;-)
> e.g. > public void myFunction(String a,String b,String c) > { Object arguments[] ; // List of argument objects; > // patternApplied(Object arguments[]) throws Exception > }
HTH
Ben
==================================================================== Companion Site: http://www.corej2eepatterns.com J2EE BluePrints: http://java.sun.com/blueprints/corej2eepatterns List Archive: http://archives.java.sun.com/archives/j2eepatterns-interest.html Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to listserv@(protected)
|
|