Here is an experiment:

For every 5 retweets that this message gets in the next 24 hours, I'll add a Refactoring Technique with a brief explanation.

Let's see how far we can get.

3, 2, 1.... Go!
Extract Method: If you have a fragment of code that can be grouped together, you can create a new method with the fragment of code and make sure the name of the method reflects the purpose of the code.
Inline Method: If you have code whose intention is as obvious as the name of the method where it resides, you can inline that method's body into the caller's body and remove the method.
Inline Temp: If you have a temporal variable that's being assigned only one time with a simple expression, you can replace that variable with the expressions.

For example, replace:
temp = object.method()
return temp

with:
return object.method()
Introduce Explaining Variable: If you have a complicated expression, you can create a temporal variable, assign the expression to it, and use a name that explains the purpose of the expression.
Extract Class: If you have a class that's doing too much, you may want to extract another class, and move the relevant methods and attributes to it.

This way you'll end up with two separate classes that will share the responsibility of the original code.
You can follow @svpino.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled:

By continuing to use the site, you are consenting to the use of cookies as explained in our Cookie Policy to improve your experience.