Reputation: 427
I was given an Interface from another team to include in my code for database logging. The Interface is filled with only abstract classes and variables/methods. What is the reason to do this?
It does not have any logic. I am simply overriding trace and isTraceEnabled when I extend Logger.
I can`t get my head around it. What is the point of having methods implemented that do nothing but return a specific value they expect?
public abstract class Logger {
public abstract void trace(String message);
public abstract bool isTraceEnabled { get; }
}
Upvotes: 1
Views: 184
Reputation: 726809
When they give you an interface like that, it means one of two things:
Logger
, and provide implementation of each of its abstract methods.Logger
to perform logging which their library provides to you, then they should provide a way for you to get an instance of a class extending the abstract Logger
class. In this case you should not be extending the class at all: you should get an instance of it upfront, store it in a variable of type Logger
, and program to its interface.Upvotes: 4