What is the best design to this class?
Posted
by
HPT
on Stack Overflow
See other posts from Stack Overflow
or by HPT
Published on 2011-01-09T10:49:41Z
Indexed on
2011/01/09
10:53 UTC
Read the original article
Hit count: 187
assume this class:
public class Logger
{
static TextWriter fs = null;
public Logger(string path)
{
fs = File.CreateText(path);
}
public static void Log(Exception ex)
{
///do logging
}
public static void Log(string text)
{
///do logging
}
}
and I have to use this like:
Logger log = new Logger(path);
and then use Logger.Log()
to log what I want.
the question is: is this a good design? to instantiate a class and then always call it's static method? any suggestion yield in better design is appreciated.
© Stack Overflow or respective owner