Re:When to refactor code
by loup-vaillant on Thursday May 16, 2013 @02:15PM
(#5720080)
Aand, while where at it, minimize the side effects. Avoid methods that modify objects, replace them by equivalent methods that create new objects. Likewise, expunge init() methods. Their code belong to constructors, factories, or curried functions. Basically, avoid the assignment statement: http://loup-vaillant.fr/tutorials/avoid-assignment
This is especially crucial when you break up your code in a myriad of small functions/methods: the whole point of refactoring was to make them readable, which means small and self contained —you don't want to keep a gazillion dependencies in mind while reading and testing a given method. Avoiding side effects is a big help there, because it will make your interfaces more explicit, and your dependencies more visible.
This is especially crucial when you break up your code in a myriad of small functions/methods: the whole point of refactoring was to make them readable, which means small and self contained —you don't want to keep a gazillion dependencies in mind while reading and testing a given method. Avoiding side effects is a big help there, because it will make your interfaces more explicit, and your dependencies more visible.