Please post your nominations for the Best of Code Review 2014 - Night and Day category.

The most dramatic improvement (nominate both the question with the most hopeless code and the answer that cleans it up the best).

In your nomination post, please make sure to include a link to the nominated answer. Include a short explanation of what makes the suggestions in the answer exceptional.

Small characters at the bottom: Only one nomination per post, nominated answers must have a creation date in 2014, downvotes don't count, and Santa reserves the right to award the top-voted nominee pair a special bounty as a token of appreciation on behalf of the Code Review community.

200_success on Kristofer Gisslén's "Complex query to count votes with a redistribution system"

This question is probably the best first post I've seen from any user:

  • It is a horrendously complex query, but working well enough to produce a plausible-looking result.
  • However, it was based on a flaw in the author's understanding of how the Single Transferable Vote system is supposed to work, which was cleared up in a chat session.
  • I am seriously impressed that a self-taught programmer could have devised something with so many nested subselects, joins, and aggregate functions.
  • The question was clearly posed, complete with a schema and test case.

To clean it up, I advocated ditching MySQL so that we could use CTEs to convert the nested queries into a logical linear progression.

Janos on "Time to Next Departure"

Converted a tedious while loop + switch with lots of duplicated code to more efficient, simpler and clearer implementation using binary search that also fixed an obscure bug.

Malachi's Answer to Stored procedure

This question was going downhill fast, and through multiple edits and a lot of cleaning came a rather good answer that cleaned up this SQL quite well.

There were a lot of Votes cast in both directions on this question before and after the cleansing.

Janos on "Given a String, return a boolean if it is a number"

Revealed bugs by implementing unit tests.

Reduced the confused and complex parsing logic in the question to a single line of regex matching.

Janos on "Score Validation"

Converted a complicated, confused, arrow-shaped code to simpler, more efficient, cleaner, unit tested solution, pleasantly surprising the OP:

Wow, would have never thought of it like this. Thanks alot! – user2999980 Nov 22 '14 at 19:29

Janos on "Converting fractions to mixed numbers"

Major cleanup of a poorly decomposed implementation, making use of Euclid's elegant gcd algorithm, resulting in an elegant, reusable, object oriented solution, including unit tests.

Janos on "Schema design for user profile"

At first glance, the schema design in the question looked quite fine and harmless. On closer look it turned out to be quite awful, and resulted in a surprisingly detailed in-depth answer.

Janos on "Determine if a sentence is a pangram"

A pangram (Greek: παν γράμμα, pan gramma, "every letter") or holoalphabetic sentence for a given alphabet is a sentence using every letter of the alphabet at least once. Pangrams have been used to display typefaces, test equipment, and develop skills in handwriting, calligraphy, and keyboarding.

Rewrote the complicated and inefficient original code to shorter, simpler, super-efficient implementation, which uses a boolean[] for storage instead of a Set<Character>, resulting on extra performance improvements thanks to much reduced boxing.

Janos on "Read from a file and pick a random line"

Gradually reworked a poorly decomposed implementation with weak cohesion to a generalized, reusable object oriented solution following properly the single responsibility principle.

You must log in to answer this question.

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