Code Monkey home page Code Monkey logo

gilded-rose-sol's Introduction

Gilded-Rose-Sol (Refactored)

This will explain the steps I took to solve this Kata

Why does this code need to be changed?

At it's current state the program is inflexible as all the bussiness rules were in one class and it was difficult to read because of the multiple "if then else" statements and all the nestings. Any introduction of a new product would require the modificication of the class because the product names are mentioned in the "if" statements, this could break the existing logic.

I have refactored the code by creating classes that inherit the "Items" class and apply the bussiness rules in those classes. This leads to the code being more readable and easy to understand. Any new product that follows the existing business rules can make use of the existing classes and new products that require new bussiness rules can be easily introduced by creating a new class which inherits the "Item" class. This leads to the exisiting code requiring no modification and eliminates the possibility to breaking code used by previous products.

gilded_rose.py

I have added 3 classes to this file:

Generic_depriciate

Which handles the depreciation of all the normal items

Cheese_appriciate

Which handles the appreciation of products such as "Aged Brie"

Pass_appriciate

Which handles appreciation of the "Backstage passes"

texttest_fixture

I have modified the "items" list so that the products use the proper class

test_gilded_rose.py

I have added several tests to test the new product throughout several days

Golden_Master.txt and New_Output.txt were created to test the output of before the code refactoring and after.

gilded-rose-sol's People

Contributors

rashiid-dev avatar

Watchers

 avatar  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.