Refactor Reorder Parameters

[CategoryRefactoring/RefactoringLanguage]

If you find 'f(a,c,b)' inconvenient, change it to 'f(a,b,c)' -- along with reversing the last two parameters of all calls.

Why would you want to do this?

But beware:


From "The little book of basic style: How to write a program you can read." by John M. Nevison, 1978 AddisonWesley ISBN 0201052474

"RULE 14: Make the line flow left to right."

"Western language since the time of the Greeks has read left to right, so direction is always lurking behind the order of the line. Take advantage of your reader's predisposition whenever possible."

(The illustration is of a window painter painting "SALE" on the inside of a window -- oriented so that HE can read it. A confused passerby, seeing the backwards "ELAS" is visibly confused.)


JohnCarter posted on the Yahoo Refactoring list:

A typical progression might be...

 A::f( Thing t, Thong tt, That ttt)
 A::g( Thong tt, That ttt)
 B::h( Thong tt, That ttt, Thing t)
 C::i( That ttt, Thong tt)
refactored to....
 A::f( Thing t, Thong tt, That ttt)
 A::g( Thong tt, That ttt)
 B::h( Thing t, Thong tt, That ttt)
 C::i( Thong tt, That ttt)
Then considering for a while all the recurrences of Thing, Thong, That and consider making a
 class ThongThing? : public Thong {
  Thing t;
  That tt;
 }

A::f( const ThongThing?& t) A::g( const ThongThing?& t)
and perhaps...
 ThongThing?::h( const B& b)
and
 C::i( ThongThing?& t)


EditText of this page (last edited November 11, 2001) or FindPage with title or text search