Skip to content

Kata Best Practices

Daniel Hall edited this page Oct 25, 2017 · 10 revisions

Be Clear

It should be clear in the instructions what the codewarrior is expected to complete in the kata. This is not always straightforward, especially for more challenging exercises. It is helpful to:

  • Include all relevant details
    • Give clear definitions of technical terms, along with references
    • Mention all of the corner cases you intend to cover in your tests
  • Motivate problems using concrete examples
  • Give examples of input/output pairs

In general, it is best to avoid:

  • Irrelevant details
  • Very abstract concepts
  • Overly complex specifications

Make Sure Content is New

Something important to consider when one is writing or editing kata: Is the concept behind this kata novel?

There are many standard exercises in programming that are well represented on Codewars. Some examples include:

  • FizzBuzz
  • Fibonacci Sequences
  • String Reversal

When working on a kata, make sure to check that it has not been done already. Every new kata should ideally teach something different.

Simplicity

A good kata should be as simple as possible. Even though there are no hard and fast rules for ensuring simplicity, the following is recommended:

  • Limit the number of corner cases tested for
  • Unless specified explicitly, only test on valid inputs declared in the description
  • Focus on testing for behavior, rather than implementation details

Testing

A good kata includes a thorough and clear set of tests that match the description. This can be difficult, even for simple kata. When writing tests:

  • Include a preloaded set of Example tests that a codewarrior can see, run, and edit if they'd like
  • Include fixed tests with full coverage of common cases and any corner cases specified in the kata description.
  • Include random tests with parameters that match the description.
  • Do not include any surprises:
    • If a special case is tested, it should be in the description
    • If you test very large inputs, say so in the description

Random tests cases for beginners

More information on the test frameworks for different languages.

This page is a stub, please consider contributing

Clone this wiki locally