Hi,
I'm working on the exception handling layer for my application.
I have read few articles on interfaces and generics. I have used inheritance before quite a lot and I'm comfortable with in that area.
I have a very brief design that I'm going to implement:
public interface IMyExceptionLogger
{
public void LogException();
// Helper methods for writing into files,db, xml
}
I'm slightly confused what I should be doing next.
public class FooClass: IMyExceptionLogger
{
// Fields
// Constructors
}
Should I implement LogException()
method within FooClass
? If yes, than I'm struggling to see how I'm better of using an interface instead of the concrete class...
I have a variety of classes that will make a use of that interface, but I don't want to write an implementation of that interface within each class.
In the same time If I implement an interface in one class, and then use that class in different layers of the application I will be still using concrete classes instead of interfaces, which is a bad OO design...
I hope this makes sense.
Any feedback and suggestions are welcome.
Please notice that I'm not interested in using net4log or its competitors because I'm doing this to learn.
Thank you
Edit:
Wrote some more code. So I will implement variety of loggers with this interface, i.e. DBExceptionLogger
, CSVExceptionLogger
, XMLExceptionLogger
etc. Than I will still end up with concrete classes that I will have to use in different layers of my application.