What does "refactoring" of a project mean ?

Discussion in 'Java' started by Anan H. Samiti, Jul 27, 2004.

  1. Can someone explain me what "refactoring" of a (java) project mean?
    I searched in google for a good explanation but found only mess (in the first 100 items).

    Anan
    Anan H. Samiti, Jul 27, 2004
    #1
    1. Advertising

  2. Anan H. Samiti wrote:
    > Can someone explain me what "refactoring" of a (java) project mean?
    > I searched in google for a good explanation but found only mess (in the first 100 items).
    >
    > Anan
    >

    Hi,
    my interpretation of code-refactoring is the following:
    Refactoring means improving/changing code(-structure) without changing
    the external behaviour of the code fragment.
    Refactoring should be done if the current codes seems to be
    unmaintainable or there is the need e.g. to provide a new/different
    Interface for some reason.
    Most IDEs support some basic refactoring-features like extracting
    interfaces or renaming objects within the whole project.

    Daniel

    P.S.: Some people think: If it's not broke, don't fix it!
    Daniel Grundmann, Jul 27, 2004
    #2
    1. Advertising

  3. Anan H. Samiti

    Jim Cochrane Guest

    In article <>, Daniel Grundmann wrote:
    > Anan H. Samiti wrote:
    >> Can someone explain me what "refactoring" of a (java) project mean?
    >> I searched in google for a good explanation but found only mess (in the first 100 items).
    >>
    >> Anan
    >>

    > Hi,
    > my interpretation of code-refactoring is the following:
    > Refactoring means improving/changing code(-structure) without changing
    > the external behaviour of the code fragment.
    > Refactoring should be done if the current codes seems to be
    > unmaintainable or there is the need e.g. to provide a new/different
    > Interface for some reason.
    > Most IDEs support some basic refactoring-features like extracting
    > interfaces or renaming objects within the whole project.


    Martin Fowler wrote a book about it. You (OP) can probably find some articles
    or excerpts of his on refactoring with a google search. Also, refactoring
    is an important ingredient of the so-called extreme programming (XP) method.

    --
    Jim Cochrane;
    [When responding by email, include the term non-spam in the subject line to
    get through my spam filter.]
    Jim Cochrane, Jul 27, 2004
    #3
  4. Jim Cochrane <> coughed up the following:
    > In article <>, Daniel Grundmann wrote:
    >> Anan H. Samiti wrote:
    >>> Can someone explain me what "refactoring" of a (java) project mean?
    >>> I searched in google for a good explanation but found only mess (in
    >>> the first 100 items).
    >>>
    >>> Anan
    >>>

    >> Hi,
    >> my interpretation of code-refactoring is the following:
    >> Refactoring means improving/changing code(-structure) without
    >> changing
    >> the external behaviour of the code fragment.
    >> Refactoring should be done if the current codes seems to be
    >> unmaintainable or there is the need e.g. to provide a new/different
    >> Interface for some reason.
    >> Most IDEs support some basic refactoring-features like extracting
    >> interfaces or renaming objects within the whole project.

    >
    > Martin Fowler wrote a book about it. You (OP) can probably find some
    > articles
    > or excerpts of his on refactoring with a google search. Also,
    > refactoring
    > is an important ingredient of the so-called extreme programming (XP)
    > method.



    Personally, I find the term silly, if not outright stupid. All refactor
    seems to mean is "redesign", or "redo", or "rewrite".

    Seems to me that there is no reason for an additional term, whose usage has
    only become in vogue relatively recently.


    --
    Onedoctortoanother:"Ifthisismyrectalthermometer,wherethehell'smypen???"
    Thomas G. Marshall, Jul 27, 2004
    #4
  5. Thomas G. Marshall wrote:
    > Personally, I find the term silly, if not outright stupid. All refactor
    > seems to mean is "redesign", or "redo", or "rewrite".


    No. It means none of these things. It is related to design, but does
    explicitly not mean large-scale from-scratch design changes that
    "redesign" implies. Instead, refactoring means small, often
    incremental changes that improve the design without changing any
    functionality or behaviour.

    I suggest you read Fowler's book, it explains all aspects of it quite well.
    Michael Borgwardt, Jul 28, 2004
    #5
  6. Anan H. Samiti

    Roedy Green Guest

    On Tue, 27 Jul 2004 21:31:26 GMT, "Thomas G. Marshall"
    <> wrote or quoted
    :

    >Personally, I find the term silly, if not outright stupid. All refactor
    >seems to mean is "redesign", or "redo", or "rewrite".


    Redesign implies starting over using your old code as a base.
    Refactoring is a ongoing process, stepwise improvement.

    In particular it mainly refers to something like algebraic factoring.
    You look for common code, encapsulate into a method, replace with
    calls to that method.

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, Jul 28, 2004
    #6
  7. Roedy Green wrote:
    > In particular it mainly refers to something like algebraic factoring.
    > You look for common code, encapsulate into a method, replace with
    > calls to that method.


    Now *that* is an interesting angle. Never thought of that similarity
    now saw it mentioned anywhere. You think it had an influence on the
    choice of the word?
    Michael Borgwardt, Jul 28, 2004
    #7
  8. Anan H. Samiti

    Jacob Guest

    Roedy Green wrote:
    > On Tue, 27 Jul 2004 21:31:26 GMT, "Thomas G. Marshall"
    > <> wrote or quoted
    > :
    >
    >
    >>Personally, I find the term silly, if not outright stupid. All refactor
    >>seems to mean is "redesign", or "redo", or "rewrite".

    >
    >
    > Redesign implies starting over using your old code as a base.


    Defined by whom? You can surely use the term "redesign" on any level
    of granularity.

    I tend to agree with Thomas W.; "refactoring" is just a fancy word
    for "redesign". Who invented it anyway? I can't remember to have seen
    it 10 years ago. We "refactored" then as well :)
    Jacob, Jul 28, 2004
    #8
  9. Anan H. Samiti

    Chris Uppal Guest

    Jacob wrote:

    > I tend to agree with Thomas W.; "refactoring" is just a fancy word
    > for "redesign". Who invented it anyway? I can't remember to have seen
    > it 10 years ago. We "refactored" then as well :)


    Indeed we did; still, it's handy to have a more specific word than
    "redesign" -- something that suggests that you are introducing a better way of
    doing the same thing. (I think I used to call it "rejigging".)

    E.g. one can redesign to improve performance, but (in current usage) one cannot
    refactor to improve performance. If you are reworking a system to -- say --
    increase throughput, then it's quite possible that /part/ of the work will be
    refactoring to /allow/ you to introduce the improved algorithms (or whatever).
    Without a word like "refactor" you have no straightforward way to express that
    distinction.

    -- chris
    Chris Uppal, Jul 28, 2004
    #9
  10. Jacob <> coughed up the following:
    > Roedy Green wrote:
    >> On Tue, 27 Jul 2004 21:31:26 GMT, "Thomas G. Marshall"
    >> <> wrote or
    >> quoted
    >>>

    >>
    >>
    >>> Personally, I find the term silly, if not outright stupid. All
    >>> refactor seems to mean is "redesign", or "redo", or "rewrite".

    >>
    >>
    >> Redesign implies starting over using your old code as a base.

    >
    > Defined by whom? You can surely use the term "redesign" on any level
    > of granularity.
    >
    > I tend to agree with Thomas W.; "refactoring" is just a fancy word
    > for "redesign". Who invented it anyway? I can't remember to have seen
    > it 10 years ago. We "refactored" then as well :)


    M. :)

    And /yes/, thank you. I am 100% suspicious of anything that comes into
    vogue. People just love to get into a tizzy over things new. I don't
    remember it 10 years ago. Perhaps I live under something heavy, but I don't
    even remember it in common usage /5/ years ago either...

    --
    While using is ok, actually /writing/ free software is a disingenuous
    activity. You can afford to write software for free only because of
    someone else somewhere actually paying for it. Just say no.
    Thomas G. Marshall, Jul 28, 2004
    #10
  11. Anan H. Samiti

    P.Hill Guest

    Thomas G. Marshall wrote:

    > People just love to get into a tizzy over things new. I don't
    > remember it 10 years ago. Perhaps I live under something heavy, but I don't
    > even remember it in common usage /5/ years ago either...


    OTOH new buzz words and 'shop talk' terms are invented all the time. If
    over time there is no need to distinguish between some lower level of
    redesign and refactoring, the new term may fall into disuse.

    Personally, I don't think I'd want to see a menu option in a language aware
    Edit/IDE which instead of saying 'refactor' says 'redesign'. I think the
    new buzzword usefully defines a range of things at that lower end.

    The other distinction between redesigning and refactoring worth mentioning is
    that refactoring is always talking about moving from one bit of design
    to another while redesign is just another design and may or may not be
    related to the existing design.

    I'd say learn to use the term refactoring, it doesn't look like one that is
    going away like other flash-in-the-pans buzzwords.

    -Paul
    P.Hill, Jul 28, 2004
    #11
  12. Anan H. Samiti

    Roedy Green Guest

    On Wed, 28 Jul 2004 10:41:38 +0200, Michael Borgwardt
    <> wrote or quoted :

    >Now *that* is an interesting angle. Never thought of that similarity
    >now saw it mentioned anywhere. You think it had an influence on the
    >choice of the word?


    Yes. Factoring means "resolving into factors/components".

    Just like finding the prime factors of an integer, encapsulating
    repetitious low-level code is finding the "prime" factors of a piece
    of code.

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, Jul 28, 2004
    #12
  13. Anan H. Samiti

    Roedy Green Guest

    On Wed, 28 Jul 2004 13:15:43 +0200, Jacob <> wrote or
    quoted :

    >Defined by whom? You can surely use the term "redesign" on any level
    >of granularity.


    That is just common usage. If someone said, "I am going to redesign
    the AWT" you would not expect him to just tweak the ScrollPane code.

    Redesign implies radical change where the entire API changes.

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, Jul 28, 2004
    #13
  14. Anan H. Samiti

    Roedy Green Guest

    On Wed, 28 Jul 2004 15:47:34 GMT, "Thomas G. Marshall"
    <> wrote or quoted
    :

    >And /yes/, thank you. I am 100% suspicious of anything that comes into
    >vogue. People just love to get into a tizzy over things new. I don't
    >remember it 10 years ago. Perhaps I live under something heavy, but I don't
    >even remember it in common usage /5/ years ago either..


    Refactor is the opposite philosophy to "if it isn't broken, don't fix
    it". Refactoring suggests code should be continuously kneaded like
    bread to get the lumps out. If you let it sit still too long it will
    crystallise and be harder and harder to change later.


    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, Jul 28, 2004
    #14
  15. Roedy Green <> coughed up the following:
    > On Wed, 28 Jul 2004 13:15:43 +0200, Jacob <> wrote or
    > quoted :
    >
    >> Defined by whom? You can surely use the term "redesign" on any level
    >> of granularity.

    >
    > That is just common usage. If someone said, "I am going to redesign
    > the AWT" you would not expect him to just tweak the ScrollPane code.
    >
    > Redesign implies radical change where the entire API changes.


    No.

    "This app needs redesign", implies redesign of the entire app. That would
    be a radical change.

    "This algorithm needs redesign", implies redesign of merely the algorithm.
    That would not be a radical change where the entire API changes.

    "This loop needs redesign", is an even finer level of granularity.

    There is no scope implication to "redesign" whatsoever.


    --
    Onedoctortoanother:"Ifthisismyrectalthermometer,wherethehell'smypen???"
    Thomas G. Marshall, Jul 29, 2004
    #15
  16. Anan H. Samiti

    Roedy Green Guest

    On Wed, 28 Jul 2004 23:07:26 GMT, "Thomas G. Marshall"
    <> wrote or quoted
    :

    >"This loop needs redesign", is an even finer level of granularity.


    Even at that level "redesign" has an implication of more radical
    restructuring than refactoring. Refactoring is more
    tidying/reorganisation rather than doing something a totally new way.

    Redesign is something you do relatively infrequently. Refactoring is
    something you do continually.

    Redesign is revolution. Refactoring is evolution.

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, Jul 29, 2004
    #16
  17. Roedy Green <> coughed up the following:
    > On Wed, 28 Jul 2004 23:07:26 GMT, "Thomas G. Marshall"
    > <> wrote or quoted
    >>

    >
    >> "This loop needs redesign", is an even finer level of granularity.

    >
    > Even at that level "redesign" has an implication of more radical
    > restructuring than refactoring. Refactoring is more
    > tidying/reorganisation rather than doing something a totally new way.


    You said:

    Redesign implies radical change where the
    entire API changes.

    Which is just plain wrong. You need to specify /what/ is being redesigned
    in order to know if it is "radical change" or if "the entire API changes".

    --
    Onedoctortoanother:"Ifthisismyrectalthermometer,wherethehell'smypen???"
    Thomas G. Marshall, Jul 29, 2004
    #17
  18. Anan H. Samiti

    P.Hill Guest

    Thomas G. Marshall wrote:
    > Roedy Green <> coughed up the following:
    >>Even at that level "redesign" has an implication of more radical
    >>restructuring than refactoring. Refactoring is more
    >>tidying/reorganisation rather than doing something a totally new way.

    >
    > You said:
    >
    > Redesign implies radical change where the
    > entire API changes.
    >
    > Which is just plain wrong. You need to specify /what/ is being redesigned
    > in order to know if it is "radical change" or if "the entire API changes".


    You seem to be ignoring Roedy's later post where he agreed with the idea that
    'redesign' could be applied to different levels of detail of the design.
    By "Radical" then we are not suggesting it always is in comparison to the whole
    application, just that the connotation is that where you want to go is probably
    not just a few steps away from where the code is now and need not have any
    relation to the original code.

    "I am going to redesign that entire routine" suggests that the body will not
    be recognizable when done, thus Roedy and others, including I, might use
    the term radical. If you're just going to change one loop into another style
    of loop or factor out a separate routine just for readability many people
    would NOT call it redesign. Meanwhile refactoring is a series of short steps;
    the kind of things that can be supported or semi-automated by smart
    language-aware editors. The kind off thing that is on the smaller end of
    redesign but also very much simply cleaning up the code.

    Those who promote re-factoring and really find it useful believe that a good
    understanding of what makes a readable, short, re-usable etc. routine when
    applied with some other rules of thumb can actually help them evolve very usable
    and often very organized designs. As Roedy said, evolution not revolution.

    But back to why there is this term refactoring. Yes, it includes a subset of
    redesign, but one of the points of having a new term is to separate out those
    simple known and well understood and named modifications that everyone should
    consider simply doing when they see one to do. It is those which have been
    given the name 'refactorings' and are in contrast to things of a more complex
    nature, and maybe only slightly more complex nature, but still more complex.

    Even those who criticize this optimistic view of the utility of re-factorings
    need to correctly define and agree upon the term refactoring in order to discuss
    how much of an architecture can really be emergent and evolved from the simplier
    code. In order to discuss the potential for tirelessly apply such smallish
    changes and to identify those changes which are automatable or semi-automatable
    there is this new term to differiate them for the larger scope of all possible
    redesign changes.

    It's all coding, some of it is re-design, some of it is now called refactoring.

    -Paul
    P.Hill, Jul 29, 2004
    #18
  19. Anan H. Samiti

    Jacob Guest

    Roedy Green wrote:

    > Refactor is the opposite philosophy to "if it isn't broken, don't fix
    > it". Refactoring suggests code should be continuously kneaded like
    > bread to get the lumps out. If you let it sit still too long it will
    > crystallise and be harder and harder to change later.


    Following this thread I'm left with this impression:

    Refactoring - Rewriting crappy code so that
    it can meet its requirements.

    Redesign - Rewriting good code so that it
    can meet new requirements.

    ;-)
    Jacob, Jul 29, 2004
    #19
  20. Anan H. Samiti

    Roedy Green Guest

    On Wed, 28 Jul 2004 18:16:23 GMT, Roedy Green
    <> wrote or quoted :

    >
    >Yes. Factoring means "resolving into factors/components".
    >
    >Just like finding the prime factors of an integer, encapsulating
    >repetitious low-level code is finding the "prime" factors of a piece
    >of code.


    In Forth, there is very low overhead for a method call, so the
    tendency is to create much smaller "prime factors", methods of just 2
    or 3 operators each. (In Forth nearly everything is an operator,
    including @ fetch and ! store.). On dedicated Forth chips, the
    call/return parameter pass is only one machine cycle. A method need
    not consume its parameters, though by convention it usually does, and
    can produce more than one result.

    In languages such as Java with a relatively high overhead for a method
    call, methods tend to be longer. With auto-inlining, the average
    length is shrinking. From a maintenance point of view, the move to
    shorter methods is a good thing because it more closely approximates
    the ideal of telling the computer each fact in only one place.

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, Jul 29, 2004
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ennio
    Replies:
    0
    Views:
    423
    ennio
    Sep 8, 2006
  2. Li Ma
    Replies:
    1
    Views:
    2,262
    Roedy Green
    Mar 9, 2009
  3. CPP beginner
    Replies:
    3
    Views:
    2,082
    Joe Smith
    Apr 6, 2009
  4. csharper
    Replies:
    3
    Views:
    597
    Mr. Arnold
    Jun 18, 2010
  5. C Barrington-Leigh
    Replies:
    1
    Views:
    1,177
    Tim Leslie
    Sep 10, 2010
Loading...

Share This Page