Coder Social home page Coder Social logo

gilded_rose_kata_elixir's Introduction

Gilded Rose Refactoring Kata

My implementation of the Gilded Rose Kata in Elixir.

How did I refactor a stream of conditionals nested nearly to infinity โˆ’ 1?

Items are pattern matched on name in the function heads with guards on sell_in. This works well for special items; falling through to default behaviour for generic items.

def update_item(%Item{name: "Aged Brie", sell_in: sell_in} = item) when sell_in <= 0 do

Mutation of items are handled by composing single-purpose mutators.

item |> age() |> degrade(4)

Tests

Execute the tests:

$ elixir gilded_rose_test.exs

Unit tests were written based on the specification in the requirements document. They are not exhaustive. For example, the minimum quality limit is only checked for generic items.

There is one acceptance test matching the expected output provided for TextTest. Rather than attempt to install TextTest I wrote a simple driver that generates the report.

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.