SlideShare una empresa de Scribd logo
1 de 20
Descargar para leer sin conexión
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
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
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
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
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.
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.
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.
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.
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
}
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”.
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.
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).
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
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.
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.
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
http://goo.gl/erofJ5
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
Extra points
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
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
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.

Más contenido relacionado

La actualidad más candente

From zero to hero with kotlin & spring boot
From zero to hero with kotlin & spring bootFrom zero to hero with kotlin & spring boot
From zero to hero with kotlin & spring bootDebora Gomez Bertoli
 
Testing stage. being ahead business with cucumber
Testing stage. being ahead business with cucumberTesting stage. being ahead business with cucumber
Testing stage. being ahead business with cucumberAlex Mikitenko
 
Frontend Development vs Backend Development | Detailed Comparison
Frontend Development vs Backend Development | Detailed ComparisonFrontend Development vs Backend Development | Detailed Comparison
Frontend Development vs Backend Development | Detailed ComparisonMariya James
 
Introducción a HTML5 & CSS3
Introducción a HTML5 & CSS3Introducción a HTML5 & CSS3
Introducción a HTML5 & CSS3jose diaz
 
The building blocks of the next web
The building blocks of the next webThe building blocks of the next web
The building blocks of the next webPier Paolo Orioli
 
GDG DevFest 2018 - Progressive Web Apps 101
GDG DevFest 2018 - Progressive Web Apps 101GDG DevFest 2018 - Progressive Web Apps 101
GDG DevFest 2018 - Progressive Web Apps 101Frances Coronel
 
Why reactive programing matter, and how PicCollage adaptive it.
Why reactive programing matter, and how PicCollage adaptive it.Why reactive programing matter, and how PicCollage adaptive it.
Why reactive programing matter, and how PicCollage adaptive it.PRADA Hsiung
 
Mukesh b.e (cse)
Mukesh b.e (cse)Mukesh b.e (cse)
Mukesh b.e (cse)mukesh gaud
 
Intro to Android (WWC Denver July 2015)
Intro to Android (WWC Denver July 2015)Intro to Android (WWC Denver July 2015)
Intro to Android (WWC Denver July 2015)Kelly Shuster
 

La actualidad más candente (11)

From zero to hero with kotlin & spring boot
From zero to hero with kotlin & spring bootFrom zero to hero with kotlin & spring boot
From zero to hero with kotlin & spring boot
 
Testing stage. being ahead business with cucumber
Testing stage. being ahead business with cucumberTesting stage. being ahead business with cucumber
Testing stage. being ahead business with cucumber
 
Frontend Development vs Backend Development | Detailed Comparison
Frontend Development vs Backend Development | Detailed ComparisonFrontend Development vs Backend Development | Detailed Comparison
Frontend Development vs Backend Development | Detailed Comparison
 
Introducción a HTML5 & CSS3
Introducción a HTML5 & CSS3Introducción a HTML5 & CSS3
Introducción a HTML5 & CSS3
 
The building blocks of the next web
The building blocks of the next webThe building blocks of the next web
The building blocks of the next web
 
GDG DevFest 2018 - Progressive Web Apps 101
GDG DevFest 2018 - Progressive Web Apps 101GDG DevFest 2018 - Progressive Web Apps 101
GDG DevFest 2018 - Progressive Web Apps 101
 
Why reactive programing matter, and how PicCollage adaptive it.
Why reactive programing matter, and how PicCollage adaptive it.Why reactive programing matter, and how PicCollage adaptive it.
Why reactive programing matter, and how PicCollage adaptive it.
 
Mukesh b.e (cse)
Mukesh b.e (cse)Mukesh b.e (cse)
Mukesh b.e (cse)
 
Android Architectures
Android ArchitecturesAndroid Architectures
Android Architectures
 
Web & Mobile
Web & MobileWeb & Mobile
Web & Mobile
 
Intro to Android (WWC Denver July 2015)
Intro to Android (WWC Denver July 2015)Intro to Android (WWC Denver July 2015)
Intro to Android (WWC Denver July 2015)
 

Destacado

A Separation of Concerns: Clean Architecture on Android
A Separation of Concerns: Clean Architecture on AndroidA Separation of Concerns: Clean Architecture on Android
A Separation of Concerns: Clean Architecture on AndroidOutware Mobile
 
Visteme con 'Clean Architecture' que tengo prisas
Visteme con 'Clean Architecture' que tengo prisasVisteme con 'Clean Architecture' que tengo prisas
Visteme con 'Clean Architecture' que tengo prisasJosé María Pérez Ramos
 
Lightning Talk - Clean Architecture and Design
Lightning Talk - Clean Architecture and DesignLightning Talk - Clean Architecture and Design
Lightning Talk - Clean Architecture and DesignDeivison Sporteman
 
Clean architecture: Android
Clean architecture: AndroidClean architecture: Android
Clean architecture: Androidintive
 
Introducing Clean Architecture
Introducing Clean ArchitectureIntroducing Clean Architecture
Introducing Clean ArchitectureRoc Boronat
 
Clean architecture
Clean architectureClean architecture
Clean architectureandbed
 
Real Life Clean Architecture
Real Life Clean ArchitectureReal Life Clean Architecture
Real Life Clean ArchitectureMattia Battiston
 
Android Clean Architecture for Dummies
Android Clean Architecture for DummiesAndroid Clean Architecture for Dummies
Android Clean Architecture for DummiesKengo Suzuki
 
Android cleanarchitecture
Android cleanarchitectureAndroid cleanarchitecture
Android cleanarchitectureTomoaki Imai
 

Destacado (12)

The Good Developer - Spanish
The Good Developer - SpanishThe Good Developer - Spanish
The Good Developer - Spanish
 
A Separation of Concerns: Clean Architecture on Android
A Separation of Concerns: Clean Architecture on AndroidA Separation of Concerns: Clean Architecture on Android
A Separation of Concerns: Clean Architecture on Android
 
Software Design patterns on Android English
Software Design patterns on Android EnglishSoftware Design patterns on Android English
Software Design patterns on Android English
 
Visteme con 'Clean Architecture' que tengo prisas
Visteme con 'Clean Architecture' que tengo prisasVisteme con 'Clean Architecture' que tengo prisas
Visteme con 'Clean Architecture' que tengo prisas
 
Effective Android UI - spanish
Effective Android UI - spanishEffective Android UI - spanish
Effective Android UI - spanish
 
Lightning Talk - Clean Architecture and Design
Lightning Talk - Clean Architecture and DesignLightning Talk - Clean Architecture and Design
Lightning Talk - Clean Architecture and Design
 
Clean architecture: Android
Clean architecture: AndroidClean architecture: Android
Clean architecture: Android
 
Introducing Clean Architecture
Introducing Clean ArchitectureIntroducing Clean Architecture
Introducing Clean Architecture
 
Clean architecture
Clean architectureClean architecture
Clean architecture
 
Real Life Clean Architecture
Real Life Clean ArchitectureReal Life Clean Architecture
Real Life Clean Architecture
 
Android Clean Architecture for Dummies
Android Clean Architecture for DummiesAndroid Clean Architecture for Dummies
Android Clean Architecture for Dummies
 
Android cleanarchitecture
Android cleanarchitectureAndroid cleanarchitecture
Android cleanarchitecture
 

Último

The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfKamal Acharya
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdfKamal Acharya
 

Último (20)

The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 

Karumi Dojo - String Calculator Kata

  • 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. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
  • 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. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
  • 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs http://goo.gl/erofJ5
  • 17. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs Extra points
  • 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. 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. 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.