Coding Dojo suggestion: the decorator kata
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.
Comments
- Anonymous
August 22, 2005
Na łamach swojego bloga Nick Malik zaproponował bardzo ciekawe ćwiczenie mające na celu utrwalenie wiedzy o dwóch wzorach projektowych: Builder i Decorator. - Anonymous
August 24, 2005
Na łamach swojego bloga Nick Malik zaproponował bardzo ciekawe ćwiczenie mające na celu utrwalenie wiedzy o dwóch wzorach projektowych: Builder i Decorator. - Anonymous
August 28, 2005
Na łamach swojego bloga Nick Malik zaproponował bardzo ciekawe ćwiczenie mające na celu utrwalenie wiedzy o dwóch wzorach projektowych: Builder i Decorator.