RSS feed [root] /design /weblog



title search:


Thu Aug 03 18:22:14 HKT 2017


Refactoring to Patterns Catalog -

Article talk about the book:

Catagories smell into "smell in class" and "smell between class" -

Known but good to remind[..]10/01/6-steps-to-master-refactoring.html

An experience sharing -[..]m/2011/05/refactor-hudson-god-class.html[..]treme-Refactoring-with-Brian-Button.aspx

Refactoring should not introduce bug... -[..]01/so-why-are-you-refactoring-again.html

A way to have formal refactoring, through Feature Clustering, Rapid Scratch Refactoring and Twisting Classes -[..]rom-michael-feathers-brutal-refactoring/

Not all code change is refactoring - , and

Some common issues about refactoring code in a team -[..]/2008/01/28/dont-be-a-refactoring-bigot/[..]01/dangers-of-premature-refactoring.html , beware taking the balance -[..]ith-beautiful-code-the-refactor-syndrome

Refactory if needed -

Refactoring, when start, when stop? -

Refactoring metric -[..]rics-based-refactoring-for-cleaner-code/

Getting rid of util class
1) If the family of methods uses different parameters, depending on optional input or representations of the same input, then consider transforming the Helper via a fluent interface using the Builder pattern: from a collection of static methods like Helper.calculate(x), calculate(x, y), calculate(x, z), calculate(y, z) we could easily get to something like newBuilder().with(x).with(y).calculate(). The helper class would then offer behaviours, reduce its list of business methods and provide more flexibility for future extensions. Callers would then use it as internal field for reuse or instantiate it where needed. The helper class (as we knew it) disappeared.
2) If the helper class provides methods which are actually actions for different inputs (but, at this point, for the same domain), consider applying the Command pattern: the caller will actually create the required command (which will handle the necessary input and offer a behaviour) and an invoker will execute it within a certain context. You may get a command implementation for each static method and your code would move from an Helper.calculate(x, y), calculate(z) to something like invoker.calculate(new Action(x, y)). Bye bye helper class.
3) If the helper class provides methods for the same input but different logics, consider applying the Strategy pattern: each static method may easily become a strategy implementation, vanishing the need of its original helper class (replaced by a context component then).
4) If the given set of static methods concerns a certain class hierarchy or a defined collection of components, then consider applying the Visitor pattern: you may get several visitor implementations providing different visit methods which would probably replace partially or entirely the previously existing static methods.
5) If none of the above cases met your criteria, then apply the three most important indicators: your experience, your competences in the given project and common sense.[..]-to-get-rid-of-helper-and-utils-classes/

Converting forloop to streaming -

Refactoring JavaScript from Sync to Async in Safe Baby-Steps -

code-refactoring-dos-donts -

(google search) (amazon search)
download zip of files only