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

208Re: [extremeperl] Re: I almost had a heart attack: you call that refactoring???

Expand Messages
  • Rob Kinyon
    Apr 1, 2005
    • 0 Attachment
      That kind of thinking is a shallow solution to the problem of a
      repeated section of work. What if the repeated code isn't the correct
      formulation of the abstract solution? I don't know what kind of
      parameters it will need or what kind of API it will need the first or
      second times I use a piece of code. By the -third- time, I have a much
      clearer concept and I can now refactor with confidence.

      Don't have the kneejerk reaction of "Must never repeat code!" Often,
      it is useful to repeat code initially so that refactoring is more

      On Apr 1, 2005 1:18 PM, Jim Keenan <jkeen@...> wrote:
      > --- 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
      > > 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
      > ________________________________
      > Yahoo! Groups Links
      > To visit your group on the web, go to:
      > http://groups.yahoo.com/group/extremeperl/
      > To unsubscribe from this group, send an email to:
      > extremeperl-unsubscribe@yahoogroups.com
      > Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
    • Show all 17 messages in this topic