Kata Four in JavaScript
After a little offline chat with Marco Fabbri, I tried to find more Kata programming problems to implement in JavaScript. (Note that not every Kata is indeed a programming problem.) I stumbled upon another easy one: Kata Four, involving a couple of simple operations on two different sets of tabular data, and a design challenge in factoring the code solving the two problems by the Don’t Repeat Yourself principle.
With a little knowledge of a scripting language and regular expressions (supposing you don’t use \W instead of \w and notice the error only after rewriting the whole expression) the provided tabular data is easily translated into HTML tables. JavaScript programming gets again interesting when dealing with the DOM and how nodes in a table are stored by the browser (e.g. getElementsByTagName vs childNodes). Factoring can be quite easy, however a further challenge can be proposed, that is to (try to) properly separate input and output (for example, the highlighting of a relevant cell in the result row) from the algorithmic part of the program, which can be not that straightforward and sometimes not even recommended when programming in JavaScript.

[...] Giulio Piancastelli (who suggested me the Function() alternative to the "evil eval"), his Kata Four in JavaScript post and by these nice presentations on JavaScript Metaprogramming: @media Ajax by Dan Webb [...]
( ? , qUeStIoNMaRk ) :: Password Strength Meter Kata :: December :: 2007 said this on December 3, 2007 at 6:54 pm |