CodelyTV / scala-finder_refactoring-kata

Incomprehensible Finder Refactoring Kata Scala

Home Page:http://codely.tv/screencasts/finder-kata-scala/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Incomprehensible Finder Refactoring Kata in Scala

Introduction

Here is the bad news: the new developer you hired has written some terrible, atrocious code. No one can understand what it does.

The good news: at least there are unit tests to prove the code is working.

You job is to refactor the code and make it readable, while keeping the code in working order (pass all tests).

Important: The new developer had a very strong Java background, so the code you'll find is not very idiomatic scala. Try to put in practice all your scala knowledge making use of the most idiomatic techniques and getting rid off the Java essence :)

How To Start

  1. Clone this repository git clone https://github.com/CodelyTV/finder-refactoring-kata-scala
  2. Install SBT
  3. Run SBT on the project directory sbt
  4. Run the tests with t. You also have available the s and ts commands which runs the scalastyle over the production and test code.
  5. Start refactoring!

The primary goal is to refactor the code in src/main/scala/tv/codely/finderKata/algorithm/Finder.scala - as it stands the code is incomprehensible.

Tips

  • Start with simple rename refactors so you can better understand the abstractions you are working with. Rename any class or any variable.
  • Move on to extract methods and making the code more modular.
  • See if you can also eliminate pattern matchings and multiple exit points from methods.

Anything is fair game, create new classes, new methods, and rename tests. The only restriction is that the existing tests have to keep working. Lean on the tests and run them after every small change to make sure you are on the right path.

How to End

You can stop when you feel the code is good enough, something you can come back to in 6 months and understand.

Helpful resources

Refactoring

Credits and other programming languages

You can also find the kata in different programming languages in isolated repositories just ready to clone and enjoy:

This kata is a Scala port of the original Incomprehensible Finder Refactoring Kata created by K. Scott Allen.

Port developed by CodelyTV and contributors 😊