Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Karumi Dojo - String Calculator Kata

2,237 views

Published on

Karumi Dojo - String Calculator Kata

Published in: Engineering
  • Be the first to comment

Karumi Dojo - String Calculator Kata

  1. 1. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs Karumi Dojo Pedro Vicente Gómez Sánchez Senior Android Developer at Karumi pedro@karumi.com @pedro_g_s github.com/pedrovgs
  2. 2. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
  3. 3. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs Irene Herranz Managing Director Alberto Gragera Technical Director Jorge Barroso Android Expert Davide Mendolia Full Stack Engineer
  4. 4. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
  5. 5. Pedro V. Gómez Sánchez - pedro@karumi.com - @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.
  6. 6. Pedro V. Gómez Sánchez - pedro@karumi.com - @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.
  7. 7. Pedro V. Gómez Sánchez - pedro@karumi.com - @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.
  8. 8. Pedro V. Gómez Sánchez - pedro@karumi.com - @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.
  9. 9. Pedro V. Gómez Sánchez - pedro@karumi.com - @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 }
  10. 10. Pedro V. Gómez Sánchez - pedro@karumi.com - @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”.
  11. 11. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs Business Rule 2 Allow the Add method to handle an unknown amount of numbers.
  12. 12. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs Business Rule 3 Allow the Add method to handle new lines between numbers (instead of commas).
  13. 13. Pedro V. Gómez Sánchez - pedro@karumi.com - @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
  14. 14. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs Rule 5 If the delimiter used is not “,” or “n” throw an exception.
  15. 15. Pedro V. Gómez Sánchez - pedro@karumi.com - @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.
  16. 16. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs http://goo.gl/erofJ5
  17. 17. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs Extra points
  18. 18. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs Extra Rule 1 Numbers bigger than 1000 should be ignored, so adding 2 + 1001 = 2
  19. 19. Pedro V. Gómez Sánchez - pedro@karumi.com - @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
  20. 20. Pedro V. Gómez Sánchez - pedro@karumi.com - @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.

×