Loading ...
Sorry, an error occurred while loading the content.

RE: [XP] Re: Duplication vs Intention Revealing code (was: Zen Refactoring)

Expand Messages
  • Steven Gordon
    If we were to convert from english to numbers, we should, for example, accept both thirteen hundred and one thousand three hundred as valid inputs and convert
    Message 1 of 42 , Jun 1, 2005
    • 0 Attachment
      If we were to convert from english to numbers, we should, for example, accept both thirteen hundred and one thousand three hundred as valid inputs and convert either input to 1300.

      -----Original Message-----
      From: extremeprogramming@yahoogroups.com on behalf of yahoogroups@...
      Sent: Wed 6/1/2005 9:21 AM
      To: extremeprogramming@yahoogroups.com
      Cc:
      Subject: Re: [XP] Re: Duplication vs Intention Revealing code (was: Zen Refactoring)



      There is one more special case:
      we usually say "thirteen hundred", not "one thousand,
      three hundred".





      [Non-text portions of this message have been removed]
    • Alex Chaffee
      ... One way I ve found to avoid this is to use IntelliJ s awkwardly named Replace Method Code Duplicates refactoring. It looks for all blocks of code that
      Message 42 of 42 , Jun 4, 2005
      • 0 Attachment
        On 6/1/05, Elizabeth Keogh <ekeogh@...> wrote:
        > I've extracted a method from a test, then applied the extraction to a
        > similar chunk in another test, but missed out one of the parameters which
        > made it different.

        One way I've found to avoid this is to use IntelliJ's awkwardly named
        "Replace Method Code Duplicates" refactoring. It looks for all blocks
        of code that have the same structure as the contents of the method,
        and replaces them with a call to that method. It's the natural
        successor to Extract Method -- perhaps a better name would be "Apply
        Method". It's not perfect, but when it works it's a thing of beauty.

        Yesterday it saved us from just the problem you mentioned. We tried to
        apply it and it *didn't* select the code we thought it would; it
        turned out we'd missed a parameter. Once we introduced that parameter
        it worked. If we'd been doing this by hand we'd have made your
        mistake.

        - A
      Your message has been successfully submitted and would be delivered to recipients shortly.