6
\$\begingroup\$

In the end, there can be only one...

We have and as synonyms. There are 372 total questions (17 unanswered). I think we only need to have one of the two... if we need one at all.

When we post code here, we are obviously looking for a code review, hence no need for a tag (which has already been blacklisted anyway).

But if you went through the front page questions, you'd probably find pretty much all questions are looking for a peer review giving tips to make their code better & cleaner.

We refactor code to enhance , to reimplement the functionality to gain in , to follow , ...there are much more specific tags out there already - "refactoring" is basically a side-effect of coming here!

Shall we burninate both?

\$\endgroup\$
4
\$\begingroup\$

I'd like to amend my previous proposal to abolish and . Instead, I propose to make them both synonyms of .

Since this Meta question was first raised, there have been three refactoring-related questions that I'm aware of:

  1. Possible improvements to Risk board game?

    This question was not tagged for , nor did it ask for it. However, one of the answers applied five refactoring techniques to achieve a significant improvement in the code.

  2. Trivia game refactoring

    In contrast, this question was tagged for , and asked whether a laundry list of 16 refactoring techniques could be applied. Of the two answers, one had nothing to do with refactoring, and the other proposed an even more important refactoring technique that the poster had missed.

  3. Moving method from derived class to base

    This question was tagged with , and asked why the resulting code was still ugly after refactoring.

The first two examples above illustrate why the tag is problematic:

  • Most of the time, when the OP asks for "refactoring" without being more specific, it's just a buzzword asking for a general improvement.
  • Once a relevant refactoring technique has been identified, applying it is a very methodical procedure — often mechanical enough to be automated in an IDE. Therefore, if the OP asks for specific refactorings to be applied, it borders on asking for code to be written.
  • However, it is within the OP's role to point out any particular concerns about the code, e.g. repetitiveness, lack of flexibility, spaghettification — in other words, .
  • Determining the applicability of refactoring rules should be a task for the reviewers. The OP doesn't even have to know anything about refactoring. Therefore, it doesn't make sense for the question to be tagged .

I think makes sense, since most of the important refactoring techniques are meant to clean up Bad Code Smells.

The third example is the closest I've seen to a good use of the tag. Even there, however, would also work, since the question is about why the code is still ugly.

\$\endgroup\$
  • \$\begingroup\$ +1 for spaghettification... and because I agree with this. \$\endgroup\$ – Mathieu Guindon Dec 12 '13 at 23:23
6
\$\begingroup\$

Although the questions often request refactoring, I've seen almost no answers that actually applied refactoring.

Strictly speaking, refactoring is a highly disciplined application of a set of rules to transform code. Step 0 is to write unit tests. Then you pick the appropriate transformation to apply, depending on the Bad Code Smell you wish to solve. Each of the few dozen refactorings has a name. Examples from the Wikipedia article are:

  • Techniques that allow for more abstraction
    • Encapsulate Field
    • Generalize Type
    • Replace type-checking code with State/Strategy
    • Replace conditional with polymorphism
  • Techniques for breaking code apart into more logical pieces
    • Componentization
    • Extract Class
    • Extract Method
  • Techniques for improving names and location of code
    • Move Method or Move Field
    • Rename Method or Rename Field
    • Pull Up
    • Push Down

I'm not sure what this tells us about refactoring.

  • Maybe the format of this website is not conducive to refactoring. Listing the intermediate refactoring steps would lead to excessively long answers, so everyone just posts the end result.
  • Maybe refactoring works better in theory than it does in practice. When code is so bad that its author requests help to refactor, it actually needs rewriting.
  • Maybe refactoring makes more sense for larger projects than the small snippets we work with on this site. One of the reasons for refactoring is to apply only well understood changes so that you can improve a huge codebase without destabilizing it.

One way to prevent careless misuse of the tag is to demand in the tag wiki that the question's author name at least one suspected refactoring transformation or describe what constitutes the Bad Code Smell, as in this example. However, it would fall to regular reviewers to enforce that policy. We would also need to do a mass clean-up of the existing 373 tagged questions. Considering the complexity of enforcing that policy, weighed against the benefit of having such a tag, I'm in favour of just abolishing both and .

\$\endgroup\$
  • 1
    \$\begingroup\$ As I've mention in my answer, we shouldn't do all that retagging ourselves. If we decide to abolish the tags, we'll have to contact SE to have the tags burned right away. Mods do not have that power. \$\endgroup\$ – Jamal Nov 25 '13 at 18:16
  • \$\begingroup\$ +1/Accept: You're describing exactly what made me write this post. \$\endgroup\$ – Mathieu Guindon Nov 25 '13 at 18:17
  • \$\begingroup\$ And I will make the other mods aware of this, in case they want to weigh in. \$\endgroup\$ – Jamal Nov 25 '13 at 18:19
  • 3
    \$\begingroup\$ Accepting this answer might be a bit premature. Even if my analysis of the situation is accurate, my conclusion could still be debatable. As @Jamal says, let's allow a day or two for others' opinions. There's no reason to rush. \$\endgroup\$ – 200_success Nov 25 '13 at 18:30
  • \$\begingroup\$ I accept to unaccept. \$\endgroup\$ – Mathieu Guindon Nov 25 '13 at 19:46
2
\$\begingroup\$

There is only one already.... points to so you are really only asking whether we need either of them.

I believe synonyms are a good thing... helps people find things when searching... So, having multiple (reasonable) synonyms actually helps things (like the synonyms for Java on StackOverflow).

As for whether is a useful tag, well, look at the questions.... and the most recent one certainly seems to have a reasonable use for it.... and given that has 133 followers ( has less than 10X that many) I think the answer is 'keep it'.

\$\endgroup\$
1
\$\begingroup\$

This is a very interesting proposal and something I haven't considered on my own.

However, I am not certain if moderators can nuke a tag that's already used with a lot of questions. That ability may lie with the powers that be. Manually removing this tag would obviously not be practical with this many questions (372 at this moment), so I would recommend against doing that.

Given the open-endedness of this proposal, I think further discussion is in order. If it's decided that this tag need not remain, I and the other moderators will decide what to do.

\$\endgroup\$
  • \$\begingroup\$ Oops the 17 are unanswered questions - indeed, it's actually 372 questions involved. \$\endgroup\$ – Mathieu Guindon Nov 25 '13 at 0:28
  • \$\begingroup\$ I think a refactor is something that generally happens to the code of people that come here and get peer reviewed. Many answerers naturally/instinctively propose ways to refactor/rewrite the OP's code as part of their reviews. \$\endgroup\$ – Mathieu Guindon Nov 25 '13 at 3:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .