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

207Re: I almost had a heart attack: you call that refactoring???

Expand Messages
  • Jim Keenan
    Apr 1, 2005
    • 0 Attachment
      --- In extremeperl@yahoogroups.com, Terrence Brannon <bauhaus@m...>
      wrote:
      >
      > <quote url=http://www.extremeperl.org/bk/refactoring>
      > if a routine is used only in one place, you keep it private within a
      > module. THE FIRST TIME IT IS USED ELSEWHERE, YOU MAY COPY IT. If you
      > find another use for it, you refactor all three uses so that they
      call
      > a single copy of the routine. In XP, we call this the Rule of Three,
      > [1] and basically it says you only know some code is reusable if you
      > copy it two times. Refactoring is the process by which you make the
      > code reusable.
      >
      > </quote>
      >
      > I don't think it requires 2 uses of
      > something to copy it. The second time you need something, you refer
      to
      > the initial use.
      >

      I agree. As MJD says, "Repeated code is a mistake!" My own personal
      rule of thumb: If you use the same code twice, put it in a
      subroutine. If you use the same subroutine in two different scripts,
      put it in a module.

      jimk
    • Show all 17 messages in this topic