I was wondering if it makes sense to have objects inherit from a class that implements the interface when dealing with dependency injections example
public interface IPeople
{
string Name { get; set; }
int Age { get; set; }
string LastName { get; set; }
}
public class CPeople : IPeople
{..implemented IPeople Methods..}
This way i only need to implement the interface in one place. I'm just not sure if this would be considered loosly coupled.
public class Dad : CPeople
{
}
public class Mom : CPeople
{
}
so that inside my controller i would have
public class Parent
{
IPeople objMom;
IPeople objDad;
Parents m_Parent;
public void factoryMethod()
{
objMom = new Mom();
objMom.Age = 32;
objMom.Name = "Jane";
objMom.LastName = "Doe";
objDad = new Dad();
objDad.Age = 25;
objDad.Name = "John";
objDad.LastName = "Doe";
m_Parent = new Parents(objMom,objDad);
}
public override string ToString()
{
return m_Parent.Mom.Name + " " + m_Parent.Mom.LastName + " is " + m_Parent.Mom.Age + " years of age, " + m_Parent.Dad.Name + " " + m_Parent.Dad.LastName + " aged " + m_Parent.Dad.Age.ToString();
}