05 March 2013

Feedback on "Unnecessary Code" Quiz Rules, Please

On 1 March, we offered a new type of daily PL/SQL quiz: Write No Unnecessary Code.

As often happens with new types of quizzes, players had lots of excellent feedback (including corrections) on how the quiz was presented.

Since we plan to offer at least another dozen quizzes of this type over the next year or so, we want to make sure that all future "unnecessary" quizzes are unambiguous and easy to understand.

Here is our current idea for how to define the quiz:

Each choice contains a combination of DDL statements and PL/SQL blocks. A choice is correct if it does not contain unnecessary code. A piece of code is unnecessary if you can remove it from the choice without changing the result of running the remaining code in that choice. 

Rules for this quiz:
  • You cannot add anything to the choice. You can only remove text - and there are limitations to what can be removed:
  • PL/SQL is composed of delimiters, identifiers and literals. Removal of part of a delimiter or literal is not allowed. You can, however, remove an  entire word (text separated by a delimiter or whitespace) from an identifier. Examples: you cannot remove "PLS_" from "PLS_INTEGER"; you cannot remove single quotes from around a literal string; you can remove "ZONE" from TIMESTAMP WITH TIME ZONE"(the result may be invalid code, but it would be a valid removal).
  • You cannot remove whitespace or comments. 
  • If it starts as a PL/SQL block, it must end that way. You cannot, in other words, remove BEGIN and END; and leave in place some part of the statements in the block as individual SQL statements.
  • A change in the resources needed to execute the choice (CPU, memory, etc.) does not, for this quiz, constitute a change in the choice. In other words, if the removal results in a choice that is slower or consumes more memory, but otherwise accomplishes the same work (inserts a row, displays text, etc.), then the choice does contain unnecessary code.
The following block, for example, contains unnecessary code and should be marked incorrect:
After removing the NULL; statement, the block will do exactly the same thing it did before. But the  following choice should be marked correct, since if you remove the "NULL" or ";", the block will no longer be valid.

I believe these rules clarify all issues raised in the Commentary for the 1 March quiz. What do you think? Are there other scenarios you have in mind that would not be addressed by these rules?

Thanks! Steven