What does "refactoring" of a project mean ?

A

Anan H. Samiti

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
 
D

Daniel Grundmann

Anan said:
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!
 
J

Jim Cochrane

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.
 
T

Thomas G. Marshall

Jim Cochrane said:
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.
 
M

Michael Borgwardt

Thomas said:
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.
 
R

Roedy Green

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.
 
M

Michael Borgwardt

Roedy said:
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?
 
J

Jacob

Roedy said:
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 :)
 
C

Chris Uppal

Jacob said:
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
 
T

Thomas G. Marshall

Jacob said:
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...
 
P

P.Hill

Thomas said:
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
 
R

Roedy Green

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.
 
R

Roedy Green

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.
 
R

Roedy Green

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.
 
T

Thomas G. Marshall

Roedy Green said:
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.
 
R

Roedy Green

"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.
 
T

Thomas G. Marshall

Roedy Green said:
On Wed, 28 Jul 2004 23:07:26 GMT, "Thomas G. Marshall"



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".
 
P

P.Hill

Thomas said:
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
 
J

Jacob

Roedy said:
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.

;-)
 
R

Roedy Green

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top