You are on page 1of 2

ALAN ISHERWOOD

For those who are unaware, core refactoring is the process of o!if"ing e#isting source
co!e in an attept to c$ean it up% &his can inc$u!e things $i'e increasing a functions
perforance, rewriting confusing sections of co!e to (e ore se$f)e#p$anator" an!
reo*ing !up$icate co!e an! rep$acing it with share! functions%
&he reason for !oing this is twofo$!% First$", it increases the aintaina(i$it" of the s"ste%
If the co!e is c$earer, the origina$ prograers intention (ecoes c$earer% &his a'es
the app$ication easier to aintain an! o!if"% Secon!$", it increases the progras
e#tensi(i$it" where(" it a" now (e possi($e to reuse parts of the origina$ co!e in other
app$ications%
+oth of these (enefits can (e *er" usefu$ for (oth the prograer an! the (usiness a$i'e%
For the prograer, there is $ess tie !e!icate! to tr"ing to wor' out what the he$$ is
going on an! ore tie actua$$" fi#ing pro($es% It a$so eans that the" can reuse (its of
co!e in other pro,ects, sa*ing the tie an! a$$owing the to focus on new pro($es%
For the (usiness, that eans $ess hours aintaining an! !e*e$oping pro,ects, which
resu$ts in $ess cost an! u$tiate$", ore profit%
-o!e refactoring .uic'$" appears to (e a win)win situation for e*er"one in*o$*e!, it is
howe*er, without its ris's% As the age)o$! pro*er( sa"s /If it isnt (ro'en, !ont fi# it0%
With e*er" $ine of co!e that is change! as a resu$t of co!e)refactoring, there is a ris' that
a!!itiona$ (ugs a" (e intro!uce! to a$rea!" wor'ing co!e% A$$ this a" resu$t in in co!e
that was pre*ious$" wor'ing (eing sent (ac' to 1A a secon! tie, a potentia$$" cost$"
e#ercise% -o!e refactoring a$so ten!s to focus on sa$$ sections of co!e2 soe wou$!
argue that there are perhaps ties when *er" $arge sections of co!e are ,ust so horri($"
written that its easier not to refactor, (ut instea! ,ust start again fro scratch an! rewrite
e*er"thing%
A$right, so now were a$$ up to spee! with what co!e refactoring is, $ets get (ac' to our
origina$ topic3 &o factor or not to factor% &here isnt one eas" answer here with the topic
un!ergoing uch !iscussion% I argue to "ou to!a" that there is no sip$e "es4no answer
that app$ies to a$$ pro,ects2 the !ecision to refactor co!e !epen!s great$" on the pro,ect
itse$f% How $arge is the pro,ect5 How $ong !o we e#pect the fina$ app$ication to (e use!
for5 Who wi$$ (e aintaining it5 What are the chances new peop$e a" (e a!!e! to the
pro,ect at a $ater stage5
At the heart of this !ecision is the $ength of tie the fina$ app$ication is e#pecte! to (e
use! for, an! how an" changes to the pro,ect are $i'e$" to (e in*o$*e! 6for e#ap$e, if
(eing use! in con,unction to an Agi$e !e*e$opent etho!, there cou$! (e an" changes
o*er an" iterations7% &o put a$$ this *er" (asica$$"2 if "ou e#pect the pro,ect to (e
an"thing other than sip$e or e#pect that the fina$ !e$i*era($e is going to (e use! for
an"thing for ore than a few onths, "ou shou$! (e refactoring "our co!e%
&he (enefits of refactore! co!e ten! to on$" to (e seen after a e!iu to $ong perio! of
tie, it is therefore on$" rea$$" (eneficia$ to use it in such situations% &he a!!e! cost of
1A an! the ris's of a!!itiona$ (ugs sip$" !ont a'e sufficient coercia$ sense to
ip$eent co!e refactoring in *er" sa$$ pro,ects%
When a !e*e$oper is to$! to refactor co!e it can (e et with resistance% &here can (e a
re$uctance to refactor rea$$" poor$" written co!e% Instea! a !e*e$oper a" prefer to sip$"
rewrite it fro scratch% &he teptation of a cop$ete co!e rewrite can (e a !angerous an!
ust (e resiste!% 8oe$ Spo$s'" wrote an interesting artic$e
6http344www%,oe$onsoftware%co4artic$es4fog99999999:;%ht$7 on this where(" he
sue! up the rea$ pro($e in one sentence3 Its har!er to rea! co!e than to write it%
Whi$st the co!e a" $oo' horri($e an! confusing, theres genera$$" a goo! reason for it3
&heres a ton of fi#es for (ugs that arent so o(*ious% -o!e refactoring coes into rea$
p$a" here an! can (e use! to sip$if" the confusing ess without reo*ing .ua$it" wor'
in !isguise%
<uch of the a,or ris's of co!e refactoring can (e offset (" using too$s !e!icate! for
refactoring as !escri(e! (" Da*i! =a$$ar!o
6http344www%i(%co4!e*e$operwor's4$i(rar"4os)ecref47 an! (" c$ose$" watching unit
tests ensuring that the resu$ts for the pre)refactore! co!e an! refactore! co!e coe out
the sae%
In suar", co!e refactoring is a powerfu$ too$ an! shou$! (e use! in the a,orit" of
cases where the pro,ect is can (e consi!ere! an"thing ore than insignificant% Its ris's
can (e offset (" using too$s !esigne! for the so$e purpose of co!e refactoring an! ("
re$"ing on unit testing% A$$)in)a$$ this process ensures that co!e is ore aintaina($e, can
(e use! in future pro,ects an! can (e .uic'$" o!ifie! when re.uire!%

You might also like