Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are a number of adages and rules of thumb about refactoring. A common one that came immediately to mind was <a href="http://en.wikipedia.org/wiki/Rule_of_three_(programming)" rel="nofollow noreferrer">The Rule of Three</a></p> <p>In professional life, we obviously have less flexibility about when refactoring can be done than we do in our personal projects. Since changes introduce risk and create work for testers (even if you have all of your regression tests automated, a change moving to production generates some amount of work for a human somewhere in your process besides the human that changed the code), you have to compute the cost to benefit ratio when deciding what and when to refactor. </p> <p>Here are a few things that I keep in mind when deciding what and how to refactor, especially when I'm working on code that will go to production:</p> <ol> <li>What is the intended benefit of the refactoring? Performance? Decreased complexity? Re-use?</li> <li>What's the level of impact of the change? High impact changes tend to have a larger amount of testing associated with them and introduce a higher amount of risk.</li> <li>Can the refactoring be executed cleanly? An incomplete refactoring can introduce more entropy than it takes away. For example, you have some methods that would make a great utility class. If you introduce the utility class, will it be possible to replace all the existing (and potentially copy-and-pasted) methods with calls to the utility class? Is there another existing utility class with similar functionality? </li> </ol>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload