Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Karumi Dojo - Kata String Calculator

Karumi
June 12, 2016
150

Karumi Dojo - Kata String Calculator

Slides used during the Karumi Coding Dojo to resolve the string calculator kata.

Karumi

June 12, 2016
Tweet

Transcript

  1. Pedro V. Gómez Sánchez - [email protected] - @pedro_g_s - github.com/pedrovgs

    Karumi Dojo Pedro Vicente Gómez Sánchez Senior Android Developer at Karumi [email protected] @pedro_g_s github.com/pedrovgs
  2. Pedro V. Gómez Sánchez - [email protected] - @pedro_g_s - github.com/pedrovgs

    Irene Herranz Managing Director Alberto Gragera Technical Director Jorge Barroso Android Expert Davide Mendolia Full Stack Engineer
  3. Pedro V. Gómez Sánchez - [email protected] - @pedro_g_s - github.com/pedrovgs

    Karumi Dojo • We are here to practice and learn. • This is a bullshit free environment. • This exercise meant to be collaborative, not competitive. • Try to open your mind to new concepts.
  4. Pedro V. Gómez Sánchez - [email protected] - @pedro_g_s - github.com/pedrovgs

    Karumi Dojo • We are here to practice Test-Driven Development. • TDD is a software development process, not a dogma. • We are going to practice pair programming. • Keep always in mind the TDD Cycle.
  5. Pedro V. Gómez Sánchez - [email protected] - @pedro_g_s - github.com/pedrovgs

    Rules: • Write enough test code so that to get a single test failure. • Write enough production code to get all your tests to pass. • Refactor until the code is Simple/Clean.
  6. Pedro V. Gómez Sánchez - [email protected] - @pedro_g_s - github.com/pedrovgs

    Rules: The TDD Cycle RED GREEN REFACTO R 3. Simplify and clean your code. 1. Write a failing test. 2. Make the code work.
  7. Pedro V. Gómez Sánchez - [email protected] - @pedro_g_s - github.com/pedrovgs

    Sum the number inside string passed as parameter: 1,2,3 = 6 String Calculator public int add(String numbers) { //Put your code here }
  8. Pedro V. Gómez Sánchez - [email protected] - @pedro_g_s - github.com/pedrovgs

    Business Rule 1 The method can take 0, 1 or 2 numbers, and will return their sum (for an empty string it will return 0) for example “” or “1” or “1,2”.
  9. Pedro V. Gómez Sánchez - [email protected] - @pedro_g_s - github.com/pedrovgs

    Business Rule 2 Allow the Add method to handle an unknown amount of numbers.
  10. Pedro V. Gómez Sánchez - [email protected] - @pedro_g_s - github.com/pedrovgs

    Business Rule 3 Allow the Add method to handle new lines between numbers (instead of commas).
  11. Pedro V. Gómez Sánchez - [email protected] - @pedro_g_s - github.com/pedrovgs

    Business Rule 4 Calling Add with a negative number will throw an exception “negatives not allowed” - and the negative that was passed. If there are multiple negatives, show all of them in the exception message
  12. Pedro V. Gómez Sánchez - [email protected] - @pedro_g_s - github.com/pedrovgs

    Rule 5 If the delimiter used is not “,” or “\n” throw an exception.
  13. Pedro V. Gómez Sánchez - [email protected] - @pedro_g_s - github.com/pedrovgs

    Tips • Baby steps. • Don’t lose the green. • Choose the language you prefer. • Refactor your code. • Build errors are not failing tests. • Follow the TDD Cycle.
  14. Pedro V. Gómez Sánchez - [email protected] - @pedro_g_s - github.com/pedrovgs

    Extra Rule 1 Numbers bigger than 1000 should be ignored, so adding 2 + 1001 = 2
  15. Pedro V. Gómez Sánchez - [email protected] - @pedro_g_s - github.com/pedrovgs

    Extra Rule 2 To change a delimiter, the beginning of the string will contain a separate line that looks like this: “// [delimiter]\n[numbers…]” for example “//;\n1;2” should return three where the default delimiter is ‘;’ . The first line is optional. all existing scenarios should still be supported
  16. Pedro V. Gómez Sánchez - [email protected] - @pedro_g_s - github.com/pedrovgs

    Extra Rule 3 Allow multiple delimiters like this: “//[delim1][delim2]\n” for example “//[*][%] \n1*2%3” should return 6.