in reply to Re: Refactoring technique?
in thread Refactoring technique?
It really doesn't matter where the input values come from, but what is the purpose of the subroutine.
You're right! Until I can give doStuff( ... ): a proper name, the parameter names are always going to be a compromise.
The problem is that the 6 blocks of code that will be replaced by the calls to doStuff(), do an aweful lot of stuff; so understanding all the stuff they do sufficiently to give it an appropriate name is quite a challenge. More so as I'm working in a language I'm only barely familiar with, and the author has made some ... what you might term politely .. dubious choices.
Eg. The code is littered with calls to a function called _OAV(), which is annotated with //Object, Attribute, Value. It looks like this:
function _OAV(oo,aa,vv) //Object, Attribute, Value { if (useSVG) { if (aa=="from") { with (oo) { setAttribute("x1",vv.split(",")[0]); setAttribute("y1",vv.split(",")[1]); } return; } if (aa=="to") { with (oo) { setAttribute("x2",vv.split(",")[0]); setAttribute("y2",vv.split(",")[1]); } return; } if (aa=="color") { with (oo) setAttribute("fill",vv); return; } if (aa=="innerText") { oo.firstChild.replaceData(0,108,vv); return; } with (oo) setAttribute(aa,vv); } else { if (aa=="fill") oo.fillcolor=vv; if (aa=="stroke") oo.strokecolor=vv; if (aa=="stroke-width") oo.strokeweight=vv; if (aa=="visibility") oo.style.visibility=vv; if (aa=="from") oo.from=vv; if (aa=="to") oo.to=vv; if (aa=="x") oo.style.left=vv; if (aa=="y") oo.style.top=vv; if (aa=="d") oo.path=vv; if (aa=="color") oo.style.color=vv; if (aa=="innerText") oo.innerText=vv; } }
Which is just horrible!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Refactoring technique?
by MidLifeXis (Monsignor) on Apr 24, 2015 at 17:24 UTC | |
by BrowserUk (Patriarch) on Apr 24, 2015 at 18:12 UTC | |
|
Re^3: Refactoring technique?
by flexvault (Monsignor) on Apr 24, 2015 at 19:50 UTC |