mercredi 30 novembre 2016

Correct approach to not instantiating a class because of X variable?

I do not know a lot of Patters but I heard that using Factory Pattern will help me with this, but I am not sure if this is the case or I have better solutions.

So, I have a class that, when calling ToString() it will return a string representation of an HTML control. When I use the constructor, it will recibe some parameters and it will use those to see if they are in a table like a row, if they exist this object will return an empty HTML string representation, so, to not instantiate the object (because it will be like empty) should I use a Factory Pattern and there return the object if it is valid or null if it is not ?

I don't have the code because I will start with it now, but I need to have this part clear so I will not "recode" some parts.

Thanks you in advance !

Aucun commentaire:

Enregistrer un commentaire