Roman Numerals Converter Code Kata summary

Brow­sing thro­ugh GitHub i came across XSolve Code Kata repo­si­tory. Code Kata #1 have two imple­men­ta­tions (PHP, C#) of Roman nume­rals conver­ter. I had some free time and wanted to imple­ment Scala version. The result is on my GitHub.

I added Roman-Arabic conver­sion compa­red to XSolve solu­tion. Project has full test cove­rage, what means every single line of code was execu­ted at least once (love that fancy Travis and Cove­ralls badges).

What is being used:

  • case clas­ses ArabicNum and RomanNum, of course it could be int and string, but hey, Scala has rich typesystem ;-)
  • whole NumConverter class is single­ton object
  • one pattern matching method
  • break() func­tions, which I find funny that Scala doesn’t have imple­men­ted such base things natively
  • FlatSpec from Scala­Test suite (BDD approach)

Be warned, vali­da­tion func­tion is ugly, conta­ins nested IFs and needs refac­to­ring, but as long as it passes tests it’s OK.

Whole code is not very „Scalish”. I consi­der myself as an Advan­ced Begin­ner on Scala accor­ding to Drey­fus Model and I don’t care ;-)

Podobne wpisy:

  1. Compu­ting file hashes using Scala
  2. Mój Geek Code
  3. Play­ing with PHP func­tio­nal way
  4. Times New Roman, Arial, Verdana i in. w Linuksie

Dodaj komentarz

Twój adres e-mail nie zostanie opublikowany.

Możesz użyć następujących tagów oraz atrybutów HTML-a: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <p> <pre lang="" line="" escaped=""> <q cite=""> <strike> <strong>