vendredi 27 mai 2016

What's wrong when to nested classes needed to create an object using decorator pattern?

Recently I try actively to use basic design patterns. But I end up these types of objects creation in my factories

$aStandardField = new Viewable(new Translatable(new Errorable(new Validatable(new Viewable(new FormField())))));

the $aStandardField is an object that if it has a value , it's value is validatable and if there is an Error , the error id will be registered there, and the error is viewable on the top of the field .... . This code looks smelly to me. So the question is how can I keep my classes small while keeping the core (FormField in the above example) untouched ,using the decorator pattern?

Aucun commentaire:

Enregistrer un commentaire