• Stars
    star
    401
  • Rank 107,625 (Top 3 %)
  • Language ABAP
  • Created about 12 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

Trip Service Kata

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

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

You can watch the video with my solution. Although quite long, I explain my whole thought process while writting tests, how I break dependencies, the reasons for refactoring and re-desining 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.

Business Rules

Imagine a social networking website for travellers:

  • You need to be logged in to see the content
  • You need to be a friend to see someone else's trips
  • If you are not logged in, the code throws an exception

Exercise Rules

  • Our job is to write tests for the TripService class until we have 100% coverage
  • Once we have 100% coverage, we need to refactor and make the code better.
  • At the end of the refactoring, both tests and production code should clearly describe the business rules

Exercise Constraints

  • We cannot manually change production code if not covered by tests, that means:
    • We cannot type type of the TripService class while still not covered by tests
  • If we need to change the TripService class in order to test, you can do so using automated refactorings (via IDE)
  • We CANNOT change the public interface of TripService, that means:
    • We cannot change its constructor
    • We cannot change the method signature
    • Both changes above might cause other classes to change, which is not desirable now
  • We CANNOT introduce state in the TripService
    • TripService is stateless. Introducing state may cause multi-thread issues

Extracted rules from here

More Repositories

1

cleancoders_openchat

Backend application for the CleanCoders series
89
star
2

Bank-kata

JavaScript
59
star
3

social_networking_kata

Exercise used for our recruitment process
Scala
32
star
4

Gilded-Rose-Kata

My implementation of the Gilded Kata.
Java
29
star
5

corporate-hotel-booking-kata

Outside-In TDD kata
Java
29
star
6

testing_legacy_code

Exercises to unit test legacy code
Java
26
star
7

bank-kata-outsidein-screencast

Java
19
star
8

salaryslipkata

Java
17
star
9

twitter-kata-java

Social Network Kata in Java
Java
10
star
10

bean-property-matcher

Hamcrest matcher to match multiple attributes of an object within a single assertion.
Java
10
star
11

cleancoders_openchat_webclient

JavaScript
10
star
12

roman-numerals-kata

9
star
13

diamond_kata

Diamond Kata
Java
7
star
14

yahtzee

Yahtzee kata in Scala
Scala
7
star
15

socrates12

legacy code
Java
5
star
16

7languages7weeks

Exercises from the book Seven Languages in Seven Weeks by Bruce A. Tate
Ruby
5
star
17

genetic-algorithm

Playing with genetic algorithm in Scala
Scala
4
star
18

gomoku_java

Java implementation of Gomoku using 2D APIs.
Java
3
star
19

shopping-basket

Java
3
star
20

mars-rover-screencast

Mars Rover Codurance screen cast.
Java
3
star
21

cqrs-activerecord

Basic Java implementation of CQRS and ActiveRecord
Java
3
star
22

bookstore_spark

Java
3
star
23

breaking-hierarchies

Extract, Inject, Kill refactoring: Breaking hierarchies
2
star
24

bowling_kata_scala

Scala
2
star
25

tww-java

TWW Java re-write
Java
2
star
26

maven_jbehave_project_template

Eclipse project skeleton using maven and jbehave
Java
2
star
27

tic-tac-toe

Tic-tac-toe kata
Java
2
star
28

online-course-bootstrap3

CSS
1
star
29

sample_app

Ruby on Rails tutorial sample application
Ruby
1
star
30

racetrack

My first adventures with groovy and grails
Groovy
1
star
31

YABE

Yet Another Blog Engine
Java
1
star
32

mars_rover_scala

MarsRover kata implementation in Scala
Scala
1
star
33

KatacombsOfDoom

Mob session during Socrates UK 2017
Java
1
star
34

tww

RoR version of TWW
Ruby
1
star
35

gilded_rose_kata

Java version for the Gilded Rose kata
Java
1
star
36

oh_hell

Java
1
star
37

codebreaker_ruby

rpsec book exercise - learning more about ruby, bdd, cucumber and rspec.
Ruby
1
star
38

testingbuilders

Code examples on how to test builders used in a blog post
Java
1
star
39

demo_app

Ruby on Rails tutorial demo application
Ruby
1
star
40

first_app

The first app for Ruby on Rails tutorial
Ruby
1
star
41

modern_c-_with_tdd_book

Makefile
1
star
42

drdanielamancuso

Static website for my sister.
Ruby
1
star