Many a times a constructor has some params are optional
while object creation. They are later on set with setters ( eg: during lazy initialization ).
My question is there can be some cases when a parameter can never be set via a constructor or a setter at all. For sake of this question, I am calling such instance variables - dormant
. Asume a standard pizze example, where Pizza(cheese, chicken, toppings).
. A customer may not want topping and may leave it dormant.
Is this considered bad practice ? If yes then are there any known patterns to clean such classes with dormant
instance variables ?