Factory Methods - III

7 September 2008

Implementation that prints messages on command prompt is presented in this post.

public class SystemTrace implements Trace {
      private boolean debug;
      public void setDebug( boolean debug ) {
            this.debug = debug;
      }
      public void debug( String message ) {
            if( debug ) {  // only print if debug is true
                  System.out.println( "DEBUG: " + message );
            }
      }
      public void error( String message ) {
            // always print out errors
            System.out.println( "ERROR: " + message );
      }
}

To use SystemTrace, we will do the following:

…
SystemTrace log = new SystemTrace();
…
log.debug( "entering log" );
…

This approach has drawbacks discussed in next post.

Continued …

del.icio.us:Factory Methods - III  digg:Factory Methods - III  spurl:Factory Methods - III  wists:Factory Methods - III  simpy:Factory Methods - III  newsvine:Factory Methods - III  blinklist:Factory Methods - III  furl:Factory Methods - III  reddit:Factory Methods - III  fark:Factory Methods - III  blogmarks:Factory Methods - III  Y!:Factory Methods - III  smarking:Factory Methods - III  magnolia:Factory Methods - III  segnalo:Factory Methods - III  gifttagging:Factory Methods - III

Top Of Page | Trackback

If you found this page useful, consider linking to it. Simply copy and paste the code below into your web site.

It will look like this: Factory Methods - III

Leave a Reply