codecop / trip-service-kata

Kata for a legacy code hands-on session. The objective is to write tests and refactor the given legacy code. -- Practice

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Trip Service Kata

Kata for legacy code hands-on session. The objective is to test and refactor the legacy TripService class.

Testing legacy code: Hard-wired dependencies

The code is related to my Testing legacy code: Hard-wired dependencies blog post. Try not reading the blog post before doing the exercise yourself.

It provides an example of existing code that needs to be unit tested. But there is one rule:

We can't change any existing code if not covered by tests. The only exception is if we need to change the code to add unit tests, but in this case, just automated refactoring (via IDE) is allowed.

Although this is a very small piece of code, it has a lot of the problems that we find in legacy code.

The end result should be well-crafted code that expresses the domain.

You can watch the video with my solution. Although quite long, I explain my whole thought process while writing tests, how I break dependencies, the reasons for refactoring and re-designing the code (tests and production code), and why certain steps are important. I also cover how often I commit and why I do it.

The video is full of tips and tricks that can be used in any language.

https://www.youtube.com/watch?v=_NnElPO5BU0

About

Kata for a legacy code hands-on session. The objective is to write tests and refactor the given legacy code. -- Practice


Languages

Language:ABAP 16.1%Language:Swift 12.4%Language:C# 12.1%Language:Objective-C 9.4%Language:Python 8.5%Language:Java 7.8%Language:Kotlin 6.4%Language:Scala 6.2%Language:PHP 5.6%Language:C++ 4.7%Language:TypeScript 3.7%Language:Ruby 3.6%Language:JavaScript 2.3%Language:Shell 1.2%