Giter Club home page Giter Club logo

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

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

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

trip-service-kata's Issues

Mocking framework

Hi,

hope find you well with this cold call.

I am an author of mocking framework for Kotlin

I see you are using mockito-kotlin.

I just want you to be aware that there is solution that fully supports Kotlin and ask to try it in your new/current projects.

I can help you if you answer to this issue.

Thanks and please star it

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.