B
Big
am a bit baffled as to why someone would take this
approach in all of our classes within the project I am
currently working on. Maybe someone else could attempt to
explain the following approach:
public class Class1 : IClass1
{
protected Class1()
{
}
public static IClass1 GetInstance()
{
return (IClass1) new Class1();
}
}
For every class in our system, there is an interface
defined. Instead of using a constructor, we use a
GetInstance method that calls new on our class but casts
the return value to the interface's type.
What advantages does this design approach have?
approach in all of our classes within the project I am
currently working on. Maybe someone else could attempt to
explain the following approach:
public class Class1 : IClass1
{
protected Class1()
{
}
public static IClass1 GetInstance()
{
return (IClass1) new Class1();
}
}
For every class in our system, there is an interface
defined. Instead of using a constructor, we use a
GetInstance method that calls new on our class but casts
the return value to the interface's type.
What advantages does this design approach have?