Lets say i have the following set of interfaces....
public interface IStart
{
void M1();
bool IsWorking { get; }
}
public interface IStartStop : IStart
{
void M2();
event EventHandler DoM1;
event EventHandler DoM2;
}
public interface IPreferencesReader : IStartStop, IDisposable
{
string CustomColumnDefinition {get;}
bool UsePricelevelDetection {get;}
void InitializePreferences();
}
Now, if i want to implement IPreferencesReader my class would look like below. This is an example of a fat interface, where i will have to provide implementation of methods that i may not need in all scenarious.
public class PreferencesReaderBase : IPreferencesReader
{
public void M1()
{
throw new NotImplementedException();
}
public bool IsWorking
{
get { throw new NotImplementedException(); }
}
public void M2()
{
throw new NotImplementedException();
}
public event EventHandler DoM1;
public event EventHandler DoM2;
public void Dispose()
{
throw new NotImplementedException();
}
public string CustomColumnDefinition
{
get { throw new NotImplementedException(); }
}
public bool UsePricelevelDetection
{
get { throw new NotImplementedException(); }
}
public void InitializePreferences()
{
DoSomeInitialization();
}
}
Can i apply any pattern for this scenario so as to refactor it?
EDIT: I can not do without this hierarchy, as in can not remove any of the interfaces.
Thanks for your interest.