Create a static factory method with the same parameters as the superclass constructor. It must contain the parameter that will take the starting values of the coded type. Depending on this parameter, the factory method will create objects of various subclasses. To do so, in its code you must create a large conditional but, at least, it will be the only one when it is truly necessary; otherwise, subclasses and polymorphism will do.https://sourcemaking.com/refactoring/replace-type-code-with-subclasses
Showing posts with label Refactoring. Show all posts
Showing posts with label Refactoring. Show all posts
Tuesday, January 12, 2016
Large Conditionals in Static Factory Methods
Friday, March 22, 2013
Refactoring is an Art
Which Choice should we work on first? Should we move logic to A first and then B, or B first and then A? How much do we work on one Choice before moving to the next? What about other refactoring opportunities we see as we go along? These are the kinds of succession questions that make refactoring an art.
Kent Beck
Kent Beck
Subscribe to:
Posts (Atom)