Original:
void SortByColumnA()
{
(blah)
(blah)
(blah)
MergeSort( start, end, originalArray, finalArray, SortTypeColumnA);
(blah)
}
void SortByColumnB()
{
(blah)
(blah)
(blah)
MergeSort( start, end, originalArray, finalArray, SortTypeColumnB);
(blah)
}
void SortByColumnC()
{
(blah)
(blah)
(blah)
MergeSort( start, end, originalArray, finalArray, SortTypeColumnC);
(blah)
}
...(D, E)...
void SortByColumnF()
{
(blah)
(blah)
(blah)
MergeSort( start, end, originalArray, finalArray, SortTypeColumnF);
(blah)
}
And so I took all the five... (or was it six) functions, kept one, deleted the rest, and tidied them up. Viola! Pleasant for the eyes. No more feeling like taking out a chopper to find the culprit who did this. Magnificent. Kon-kon.
After:
void SortColumn(SortTypeColumn sortTypeColumn)
{
(blah)
(blah)
(blah)
MergeSort( start, end, originalArray, finalArray, sortTypeColumn);
(blah)
}
And I never thought i would write a techy-blog post like this.
Just needed to get it out of my system. I really wanted to tear out my hair when I saw functions A, B, C, D, E, F, with 98% similarity, and only a different variable/function name. Obviously the result of a quick copy-and-paste, modify name, submit and check-in operation. RRRRGGGH.
No comments:
Post a Comment