16
\$\begingroup\$

I posted this question about how to rewrite a C# algorithm in fewer lines of code, preferably using extension methods, which prompted a discussion in the comments about whether it was appropriate for Code Review. I'd originally considered posting it to StackOverflow, but then I read this Meta answer from Jeff Atwood, and decided that since I was asking about how to make my code look more elegant, not about fixing a bug, it belonged on Code Review.

I didn't intend it as inviting people to solve a puzzle, and while I'd like to make it shorter, I still want it to be readable and easily modified, so I don't think it's a Code Golf question.

Looking at the Code Review FAQ, though, I'm not sure if it belongs here. I tend to think of extension methods as a cleaner way to program in .NET, but I suppose there's a difference between trying to write code that "looks better" and actually trying to implement best practices.

This kind of thing comes up for me a lot in my work, so I'd like to get some input about whether or not I should post these sorts of "beautifying" questions to Code Review, or if I should only ask about software design principles or algorithm efficiency.

\$\endgroup\$
17
\$\begingroup\$

From the close queue I can see that three people voted to close and three voted to leave open, meaning that the question is gone from the close queue. Even though it has four close votes, I consider it on-topic. Here's why:

  • Your question contains code
  • You wrote that code
  • It looks like actual code from a project rather than pseudo-code or example code
  • You want the code to be good code (i.e. not code-golfing, obfuscation, or similar)
  • The code works
  • Even though you're not explicitly asking for feedback about any or all facets of the code, you are also not not-asking about it (double-negation FTW!)

The four close voters has used this close reason:

Questions asking for code to be written to solve a specific problem are off-topic here as there is no code to review.

I have to disagree with these voters because:

  1. You're not asking for code to be written, you're asking about if there is an easier way to do what you are doing
  2. The problem to solve has already been solved, you're just asking about how it can possibly be solved easier / in a different way
  3. There is code to review

Conclusion:

Your question is on-topic.

\$\endgroup\$
10
\$\begingroup\$

Here's a short guideline I use as to what belongs where:

  • Software Engineering - Algorithms, concepts, maybe minimal code or math to clarify.

  • StackOverflow - Broken, non-working code.

  • CodeGolf - A puzzle is given. Everyone else does the code, as short as possible.

  • CodeReview - You need working code for review, which is being subjected to:

    • Readability - Code can be understood. This would include beautifying it and keeping the code as short and simple but still readable. I think it's this that keeps the code from getting "golfed". For instance, I can do some very complex ternary to vastly shorten my code, but that sacrifices readability.

    • Scalability - The code is easily extended with features. Golfed code typically just addresses one issue, the puzzle. Scalability, however, requires your code to be adaptable, and would require additional logic to handle extras.

    • Maintainability - The code can easily be debugged and fixed. Golfed code is hard to read, and not good for maintainability.

    • [some other factors] - Efficiency, least CPU cycles, least overhead, proper use of syntax, conventions, better algorithms etc.

\$\endgroup\$
  • 2
    \$\begingroup\$ This would be a good general answer to link people to if Programmers was also in the list. Unfortunately though, I don't think that you're answering the OP's specific question about whether or not that particular question is on-topic here or not. \$\endgroup\$ – Simon Forsberg Mar 8 '14 at 10:36
  • 3
    \$\begingroup\$ @SimonAndréForsberg I just created this list as a guideline. I think his "beautifying" query belongs under readability. \$\endgroup\$ – Joseph Mar 8 '14 at 10:43

You must log in to answer this question.

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