[slf4j-dev] Better printing method signatures?

Ceki Gülcü listid at qos.ch
Thu Jun 16 22:30:36 CEST 2005


Hello,


For me, the real choice is between

  debug(String)

and

  debug(Object)

The signature of the other methods can be more or less "deducted" from the 
above choice.

To answer your question, let me first label the methods you mention:

  nhA)  debug( String, Object, Throwable );
  nhB)  debug( String, Throwable, Object );
  nhC)  debug( String, Object[] )
  nhD)  debug( String, Object, Object[] );
  nhE)  debug( String, Object[], Object );
  nhF)  debug( String, Throwable, Object[] );
  nhG)  debug( String, Object[], Throwable );


I think nhD and nhE are ambiguous. For example, the following statement 
will not compile.

    debug("hello", new Object[] {}, new Object[] {});

Moreover, I fail to see a need for nhD or nhE, if you have nhC.

I also do not understand when or why you would want to use nhA, mhB, nhF or 
nhG. As I see it,

   cgA) debug(String, Throwable)
   cgB) debug(Object, Throwable);
   cgC) debug(Object);

are the only variants that will admit a parameter of type Throwable. (Note 
that cgA and cgB conflict, so only one can be present in the SLG4J Logger 
interface).

I'll try to follow up with a more complete answer tomorrow.


At 05:27 AM 6/16/2005, Niclas Hedhman wrote:
>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
>_______________________________________________
>dev mailing list
>dev at slf4j.org
>http://slf4j.org/mailman/listinfo/dev

-- 
Ceki Gülcü

   The complete log4j manual: http://www.qos.ch/log4j/





More information about the slf4j-dev mailing list