Git Product home page Git Product logo

yusuflimdiwala / trip-service-kata Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sandromancuso/trip-service-kata

0.0 1.0 0.0 1.56 MB

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

Shell 1.09% JavaScript 2.09% Ruby 3.25% C++ 4.34% Python 7.21% PHP 5.14% Objective-C 8.59% Java 11.26% Scala 5.64% Go 1.68% C# 11.04% F# 3.01% Kotlin 5.79% TypeScript 3.35% ABAP 14.63% Swift 11.32% CMake 0.55%

trip-service-kata's Introduction

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

trip-service-kata's People

Contributors

sandromancuso avatar c089 avatar theunic avatar archel avatar pcaldredbann avatar gepparta avatar martinsson avatar jajeffries avatar kudashevs avatar simons avatar yusuflimdiwala avatar wise86-android avatar hkirk avatar felixble avatar bricef avatar andreafrancia avatar alastairs avatar sblaut avatar kgashok avatar tvidal-net avatar remosu avatar seblm avatar gscalzo avatar franziskas avatar emiliogq avatar cotonne avatar christian-fei avatar brehberg avatar avernois avatar ananogal avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.