java - Pseudo-Backwards Builder Pattern? -
in legacy codebase have large class far many fields/responsibilities. imagine pizza object.
it has highly granular fields like:
- haspepperoni
- hassausage
- hasbellpeppers
i know when these 3 fields true, have supreme pizza. however, class not open extension or change, can't add pizzatype, or issupreme(), etc. folks throughout codebase duplicate same if(a && b && c) issupreme)
logic on place. issue comes quite few concepts, i'm looking way deconstruct object many subobjects, e.g. pseudo-backwards builder pattern.
pizzatype pizzatype = pizzaunbuilder.buildpizzatype(pizza); //pizzatype.supreme dough dough = pizzaunbuilder.builddough(pizza);
is right approach? pattern exist already?
how adapter pattern?
basically wrapper class has functionality want can go , forth pizza class.
menupizza mypizza = new menupizza(pizza); pizzatype pizzatype = mypizza.getpizzatype(); doughtype doughtype = mypizza.getdoughtype();
and provide reverse functionality...
menupizza otherpizza = new menupizza(pizzatype.supreme, doughtype.sour); pizza pizzapojo = otherpizza.getpizzapojo();
Comments
Post a Comment