Solution Code Blocks

  • Sep 10, 2013

What is the correct solution block?

The correct solution block is a fully working example that validates properly. Depending on
what type of technique you pick to categorize your kata, the solution may be just
one of many ways to solve the kata. In the case of a bug fix kata, your solution
will probably be the most obvious solution for fixing the code.

How do I validate that the solution is correct?

You can use the test fixture editor to create the code that will validate both
your solution and also the solution that other code warriors (users) come up with. Check
out the test fixture help tab for more details on writing test fixtures.

What is the "Solution Setup" for?

The solution setup is what a code warrior will first see when they
attempt to solve your kata. Its the boiler plate code for the kata
that helps set the stage. If you are creating a bug fix kata then the code
will be the invalid version that a code warrior will need to fix. If you are
creating an algorithm or reference kata then the solution setup may just be an empty function
with some comments to help get them started. If you are creating a refactoring
kata then the code will possibly be a big hunk of messy code that should be refactored
so that it uses a cleaner API that the test fixture will test against.

You are required to have some form of solution setup for the user. If you wish to not have
actual code setup for them then you can just include some comments to help get them started.

What is the "Preloaded" code for?

This is code that will be loaded before the solution code within the execution path.
This allows you to setup code that can be used by the warrior's solution, but not directly
edited within the solution code.

The execution order of all of the code blocks is
"Preloaded" -> "Solution" -> "Test Fixture". The preloaded code block is optional and you do
not have to use it if you don't need to.

You can use this code block to preload code that is required for the solution to run, but
is not a part of the solution itself. The preloaded code is not visible to users so you
can do whatever trickery you need to in order to prevent someone from trying to cheat. The best practice is to show whatever "preloaded" code that a user will need to see within the description section. This allows you to pick and choose what a user should and shouldn't see. Don't forget
when using the description that it is markdown and you can use three backticks (```) plus the language name to render a colorized code block.

Discuss:

Loading comments...