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

Design Agility? (was: Duplication vs Intention Revealing code)

Expand Messages
  • Steve Bate
    Let s say your customer tells you there s an additional requirement. Your code must also support representing numbers as German words. Although this is a
    Message 1 of 42 , Jun 1 10:53 AM
      Let's say your customer tells you there's an additional
      requirement. Your code must also support representing numbers
      as German words.

      Although this is a simpler requirement than full I18N I
      suspect it will have a significant impact on the designs. How
      could we measure the agility of the existing designs? For
      example, would the percentage of statements modified be a
      useful metric for this purpose? Could that percentage also
      tell us whether the original design "evolved" or a new one
      was created?

      Which design would be the most agile given the additional
      requirement and why?

      Steve
    • 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 8:03 AM
        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.