I try to apply SOLID principles in my project's class design.Are there any exceptions of SOLID principles? Do we HAVE to apply these principle DEFINITILY.For example i prepared a factory class.
class XAdderFactory
{
private Person _person;
public bool PersonHasNoRecords
{
get
{
return string.IsNullOrEmpty(_person.HasXRecords);
}
}
public XAdderFactory(Person person)
{
this._person = person;
if (PersonHasNoRecords)
{
new XListMakerAFactory(person);
}
else
{
new XListMakerB(person);
}
}
}
This class never confirms the OCP principle.
New type list makers maybe required in future and i must add new else if block .
Is my design bad?
Or are there exceptions of SOLID princples that not mentioned too much?
I am not sure but my example comply "Strategic Closure" of OCP? If you have another examples about SOLID exceptions,i think it would be helpfull for designers.
Aucun commentaire:
Enregistrer un commentaire