I ran across a posting by Robert Martin on the Coding Dojo and I admit to being intrigued.  I’m running a low-priority thread, in the back of my mind, looking for good examples of kata to use in a coding dojo.

Here’s one that I ran across in a programming newsgroup.

You have an app that needs to be able to read a CSV file.  The first line of the file specifies the data types of the fields in the remaining lines.  The data type line is in the format

[fieldname:typename],[fieldname:typename],…,[fieldname:typename]

For example:
[name:string],[zipcode:int],[orderdate:date],[ordervalue:decimal]

you must use a decorator pattern.  The decorator must be constructed using a builder pattern that consumes the data type line.  Output is a file in XML format

<file>
   <row><name>Joe Black</name><zipcode>90210</zipcode>… </row>
</file>

Any row that doesn’t match the specification will not produce an output line.  The output will pick up with the next line.  The file, when done, must be well-formed.

Of course, with a kata, the only thing produced at the start is the set of unit tests (and perhaps, in the interest of time, the frame of the classes from a model).  The rest is up to the participants.

Comments are welcome, of course.

By Nick Malik

Former CIO and present Strategic Architect, Nick Malik is a Seattle based business and technology advisor with over 30 years of professional experience in management, systems, and technology. He is the co-author of the influential paper "Perspectives on Enterprise Architecture" with Dr. Brian Cameron that effectively defined modern Enterprise Architecture practices, and he is frequent speaker at public gatherings on Enterprise Architecture and related topics. He coauthored a book on Visual Storytelling with Martin Sykes and Mark West titled "Stories That Move Mountains".

3 thoughts on “Coding Dojo suggestion: the decorator kata”
  1. Na ?amach swojego bloga Nick Malik zaproponowa? bardzo ciekawe ?wiczenie maj?ce na celu utrwalenie wiedzy o dw&#243;ch wzorach projektowych: Builder i Decorator.

  2. Na ?amach swojego bloga Nick Malik zaproponowa? bardzo ciekawe ?wiczenie maj?ce na celu utrwalenie wiedzy o dw&#243;ch wzorach projektowych: Builder i Decorator.

  3. Na ?amach swojego bloga Nick Malik zaproponowa? bardzo ciekawe ?wiczenie maj?ce na celu utrwalenie wiedzy o dw&#243;ch wzorach projektowych: Builder i Decorator.

Leave a Reply

Your email address will not be published. Required fields are marked *

4 − three =

This site uses Akismet to reduce spam. Learn how your comment data is processed.