[slf4j-dev] Better printing method signatures?

Niclas Hedhman niclas at hedhman.org
Thu Jun 16 05:27:43 CEST 2005


On Thursday 16 June 2005 04:30, Ceki Gülcü wrote:
> I am thinking of reducing the set to 3 as follows:
>
>   void debug(Object msg);
>   void debug(Object msg, Object param1);
>   void debug(Object msg, Object param1, Object param2);

> Any better ideas? Comments?

The only downside that I can see is the "Auto show doc" that IDEs are doing. 
The javadoc for each method will become either very generic (i.e. doesn't be 
descriptive enough) or very detailed and large with a lot of complex formulas 
of how things are resolved.

I think I would still recommend that first argument is "String message", to 
reduce the documentation complexity. Also outputting an Throwable without any 
further description is probably only suitable for debug/trace, and putting a 
'null' or "" for those cases are a reasonable trade-off, I think.

Question is would these also be special cases;

   debug( String, Object, Throwable );
   debug( String, Throwable, Object );
   debug( String, Object[] )
   debug( String, Object, Object[] );
   debug( String, Object[], Object );
   debug( String, Throwable, Object[] );
   debug( String, Object[], Throwable );

Passing more than two arguments have its use-cases.
With free argument passing like above, it will become very "messy" to decode. 
OTOH, throwing a runtime exception also seems like the wrong idea.

WDYT?


Cheers
Niclas



More information about the slf4j-dev mailing list