Giter VIP home page Giter VIP logo

pencilkata's Introduction

Pencil Durability Kata

The purpose of the Pencil Durability Kata is to write code to simulate, first coarsely and then more faithfully, an ordinary graphite pencil. It includes writing and editing text, point degradation, using the eraser, and sharpening the pencil. The point of this kata is to provide a larger-than-trivial exercise that can be used to practice TDD. A significant portion of the effort will be in determining which tests should be written and, more importantly, written next.

The pencil object has several major functions that the user can use it for. It can write text, edit text, erase text, and be sharpened. All of these functions effect various state variables of the pencil: length, durability, and eraser [durability].

The text functions take two variables, one which is the change to be made (text to be added or deleted), and then the paper to which the change is occuring on. The paper may already contain text.

The code was developed in a test-driven development style, writing tests based off of the specification here: https://github.com/PillarTechnology/kata-pencil-durability#point-degradation and then writing more code until the tests pass. You can see this in my git commit history here: https://github.com/bschwyn/pencilKata/commits/master

Download and installation

To download the pencil kata use:

git clone https://github.com/bschwyn/pencilKata

and use pip to install pytest:

pip3 install pytest

The tests can then be run by typing

pytest, py.test or pytest pencilKata in the pencilKata directory.

Future work

As the specification becomes more complete, here are some changes I could imagine being added to the pencilKata code.

  • more strictly defining the results of edit collisions (i.e. do collisions of the same character result in an @ sign or the same character?)
  • separation of the 'paper' into it's own separate class, with different characteristics. Perhaps different paper degrades pencils differently or has different effects on the text. Rather than string concatenation, paper objects would probably need an 'add text' method that pencil functions would access. Pencil methods would take a paper object, modify it, and then return the modified paper object.
  • You could a Writing-Instrument interface which is implemented by different objects such as Pen, Pencil.

Acknowlegements

This kata was written to follow the spec described here: https://github.com/PillarTechnology/kata-pencil-durability#point-degradation, by Pillar Technologies. All of the code is my own.

pencilkata's People

Contributors

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