Refactoring in IntelliJ IDEA, Live by Robert C. Martin (Uncle Bob)

It’s still over 3 months before the holiday season, but we just got a great present from our long time friend Robert C. Martin (Uncle Bob) — a live refactoring demo performed by the legendary software expert himself. He’s, of course, using IntelliJ IDEA!

Check out this video where Uncle Bob shows some refactoring techniques transforming a “large and ugly” function into a clean and readable piece of Java code, using such refactorings as Rename, Extract Method, Inline Variable, and others. We learn something new every time we watch experts like Uncle Bob.


You can also watch this video on JetBrains TV.

The video is part of the highly recommended “Clean Code” series of educational “code-casts.” More Clean Code videos are available at cleancoders.com.
Robert C. Martin (Uncle Bob) is the Master Craftsman at 8th Light Inc., 8thlight.com.

As a separate note, Robert C. Martin has recently released a new book “The Clean Coder: A Code of Conduct for Professional Programmers” which we think is a must read for every professional software developer.

Enjoy the demo and develop with pleasure!
-The JetBrains Team

This entry was posted in Demos, Tips & Tricks and tagged . Bookmark the permalink.

12 Responses to Refactoring in IntelliJ IDEA, Live by Robert C. Martin (Uncle Bob)

  1. Denis Tulskiy says:

    since when does idea tell you why you cannot extract a method? or is that only in ultimate edition?

  2. yole says:

    Denis,
    As far as I remember the warning about multiple output variables has always been there; the “Extract Method Object” refactoring is new in IDEA 8 or 9. This feature behaves exactly the same in IntelliJ IDEA Ultimate and Community Edition.

  3. Dragan Stankovic says:

    Refactoring at 10:18 (makeChildFromTag(HtmlTag) ) has two casts: one on method call where element variable is casted to HtmlTag (which is fine) and other one inside method definition which is superfluous since the method is already defined to require parameter of HtmlTag type.

  4. dashin says:

    Link to 8thlight.com is broken

  5. Sagara says:

    It takes so long for him to re-type existing code, why didn’t he copy it…
    Also, he selects expressions using mouse instead of using “Extend selection”.

  6. Anton says:

    Lol, why is this cleaner?
    Some changes were nice but I for once prefer to read 1 method with 15lines than 5 methods with 3 lines each…

    I really disagree on most of the changes. Most are just “smartass” changes that actually make the code harder to read for not-so-bright programmers.

  7. Wilson says:

    What are the shortcuts for renaming variables and all occurrences without a pop up appearing? I know shift f6, but he is doing without a rename pop up appearing?

  8. Anna Kozlova says:

    You need to have option Settings|Editor|Enable in-place mode on.

  9. Wilson says:

    Hi Anna, i have the : Settings | Editor | Enable in-place checked, if i select some variable and rename it the occurrences are not updated, if i press shift + f6 the pop up appears, what shortcut i need to press when selecting the var? TIA

    IDEA 11.1.3, Build IU-117.798
    Apple JDK 1.6.023

  10. Wilson says:

    Oh sorry, it’s working! I did change the setting but didn’t remember when, after restarting idea i got it with the shift + f6, great! Thanks.

  11. Steven Jeuris says:

    So Uncle Bob is still going strong on his function hell frenzy. :/

    “Oh heavens, there are boolean flags being set.”

    Yes, … let’s solve that by hiding them and creating a class.
    “I made this class so that I could put some of these horrible boolean flags into it, taking them out of the local scope and into a slightly larger class scope.”

    At least he realizes he is unnecessarily expanding scope.

    If somebody can explain me why his changes are considered to be good, please enlighten me. I already discussed the topic in detail after reading his book ‘Clean Code’ on my blog, but still haven’t heard any proper counter arguments yet.
    http://whathecode.wordpress.com/2010/12/07/function-hell/

    The only argument I somewhat can agree with is smaller functions are easier to test. But creating dozens of functions without thinking twice about the overall design? It gives me the shivers.

  12. jmotson says:

    >If somebody can explain me why his changes are considered to be good, please enlighten me.

    Uncle Bob’s changes are good because he is simplifying the code. When your functions are 4 lines long, they have very little complexity and thus easy to test.

    This comes at a trade-off of having a lot of small functions. However, small functions are more testable than large functions.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">