Manuela Munaretto, Gabriele Lana, Filippo Liverani - Women super code lab – Improve your skills with TDD Pair Programming code session | Codemotion Milan 2015
An amazing opportunity for all the coders to improve their programming skills in a safe and thrilling environment. Our lab is a 4 hours intensive practice event, focusing on the fundamentals of software development and design, away from the pressures of ‘getting things done’, the attendees would experience a significantly improvement in their coding proficiency. The iterations will be carried out using Pair Programming practice of TDD letting each participant choose the language and preferred paradigm. Prior knowledge of coding is requested. Session will be delivered in italian.
Manuela Munaretto, Gabriele Lana, Filippo Liverani - Women super code lab – Improve your skills with TDD Pair Programming code session | Codemotion Milan 2015
1. MILAN 20/21.11.2015
Women super code lab: an amazing
opportunity for all the coders to improve
their programming skills in a safe and
thrilling environment.
Manuela Munaretto - XPeppers
2. MILAN 20/21.11.2015 - Manuela Munaretto
Agenda
25’: welcome and
introduction to the codelab
5’: Pair forming
35’: Session #1
10’: retrospective
35’: Session #2
60’: lunch break
10’: retrospective
5′: Pair forming
45’: Session #3
10’: retrospective
5’: break
35’: final retrospective +
Q&A
10. MILAN 20/21.11.2015 - Manuela Munaretto
Test Driven Development: How
1. Add a little test
2. Run all tests and fail
3. Make a little change
4. Run the tests and succeed
5. Refactor to remove duplication
11. MILAN 20/21.11.2015 - Manuela Munaretto
Test Driven Development: Why
★ What needs to be done
★ Requirements are nailed down
★ Immediate feedback
★ System design
★ Only the features you wanted
13. MILAN 20/21.11.2015 - Manuela Munaretto
4 rules of simple design: How
1. Passes all the tests
2. Expresses every idea that we need to express
3. Contains no duplication
4. Minimal method, classes and modules
14. MILAN 20/21.11.2015 - Manuela Munaretto
4 rules of simple design: Why
★ High cohesion and loose coupling
★ Compact
★ Modular code
★ Expressing all the important ideas of the system
16. MILAN 20/21.11.2015 - Manuela Munaretto
Pair Programming: How
1. Sit side by side in front of the monitor
2. Switch roles often
3. Switch pair daily
4. Appropriate workspace layout
5. Take a break from working together
6. Pair programming is chatting
17. MILAN 20/21.11.2015 - Manuela Munaretto
Pair Programming: Why
★ It’s funny
★ Less frustration
★ More focused
★ Less bugs
★ Higher quality fighting poor practices
★ Continuous code review
★ Collective code ownership
19. MILAN 20/21.11.2015 - Manuela Munaretto
String Calculator: a kata
Kata is often described as a set sequence of karate
moves organized into a pre-arranged fight against
imaginary opponents.
A system of individual training exercises in karate and
other martial arts.
20. MILAN 20/21.11.2015 - Manuela Munaretto
String Calculator: Why
The following is a TDD Kata- an exercise in coding,
refactoring and test-first, that you should apply daily.
Try not to read ahead.
Do one task at a time. The trick is to learn to work
incrementally.
Make sure you only test for correct inputs. There is no
need to test for invalid inputs for this kata
21. MILAN 20/21.11.2015 - Manuela Munaretto
String Calculator: Step 1
Create a simple String calculator with a method int Add
(string numbers)
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”
2. Start with the simplest test case of an empty string and
move to one and two numbers
3. Remember to solve things as simply as possible so
that you force yourself to write tests you did not think
about
4. Remember to refactor after each passing test
22. MILAN 20/21.11.2015 - Manuela Munaretto
String Calculator: Step 2
Allow the Add method to handle an unknown amount of
numbers
23. MILAN 20/21.11.2015 - Manuela Munaretto
String Calculator: Step 3
Allow the Add method to handle new lines between
numbers (instead of commas).
1. the following input is ok: “1n2,3” (will equal 6)
2. the following input is NOT ok: “1,n” (not need to
prove it - just clarifying)
24. MILAN 20/21.11.2015 - Manuela Munaretto
String Calculator: Step 4
Support different delimiters
1. 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 3 where the default delimiter is ‘;’ .
2. the first line is optional. All existing scenarios should
still be supported
25. MILAN 20/21.11.2015 - Manuela Munaretto
String Calculator: Step 5
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
26. MILAN 20/21.11.2015 - Manuela Munaretto
String Calculator: Step 6
Numbers bigger than 1000 should be ignored,
so adding 2 + 1001 = 2
27. MILAN 20/21.11.2015 - Manuela Munaretto
String Calculator: Step 7
Delimiters can be of any length with the following format:
“//[delimiter]n”
for example:
“//[***]n1***2***3”
should return 6
28. MILAN 20/21.11.2015 - Manuela Munaretto
String Calculator: Step 8
Allow multiple delimiters like this:
“//[delim1][delim2]n”
for example
“//[*][%]n1*2%3”
should return 6
29. MILAN 20/21.11.2015 - Manuela Munaretto
String Calculator: Step 9
Make sure you can also handle multiple delimiters with
length longer than one char
30. MILAN 20/21.11.2015 - Manuela Munaretto
Resources
Extreme Programming: A gentle introduction
http://www.extremeprogramming.org/
Test-Driven Development: By Example - Kent Beck
http://www.amazon.
it/dp/0321146530/ref=cm_sw_r_tw_dp_5rgrwb1F002NJ
Cunningham & Cunningham, Inc.
http://c2.com/
31. MILAN 20/21.11.2015 - Manuela Munaretto
Resources
String Calculator
http://osherove.com/tdd-kata-1/