33
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

Manuela Munaretto, Gabriele Lana, Filippo Liverani - Women super code lab – Improve your skills with TDD Pair Programming code session | Codemotion Milan 2015

Embed Size (px)

Citation preview

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

MILAN 20/21.11.2015 - Manuela Munaretto

Agenda

25’: welcome and introduction to the codelab5’: Pair forming35’: Session #110’: retrospective35’: Session #2

60’: lunch break

10’: retrospective5′: Pair forming45’: Session #310’: retrospective

5’: break

35’: final retrospective + Q&A

MILAN 20/21.11.2015 - Manuela Munaretto

Our tools

★ Prerequisites★ TDD★ 4 rules of simple design★ Pair Programming

MILAN 20/21.11.2015 - Manuela Munaretto

MILAN 20/21.11.2015 - Manuela Munaretto

Prerequites: How

1. Prior knowledge of coding2. Laptop3. Development Environment4. Test Libraries

MILAN 20/21.11.2015 - Manuela Munaretto

Prerequites: Why★ Improve your skills★ Intensive practice event★ Away from the pressures

MILAN 20/21.11.2015 - Manuela Munaretto

MILAN 20/21.11.2015 - Manuela Munaretto

MILAN 20/21.11.2015 - Manuela Munaretto

MILAN 20/21.11.2015 - Manuela Munaretto

Test Driven Development: How

1. Add a little test2. Run all tests and fail3. Make a little change4. Run the tests and succeed5. Refactor to remove duplication

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

MILAN 20/21.11.2015 - Manuela Munaretto

MILAN 20/21.11.2015 - Manuela Munaretto

4 rules of simple design: How

1. Passes all the tests2. Expresses every idea that we need to express3. Contains no duplication4. Minimal method, classes and modules

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

MILAN 20/21.11.2015 - Manuela Munaretto

MILAN 20/21.11.2015 - Manuela Munaretto

Pair Programming: How

1. Sit side by side in front of the monitor2. Switch roles often 3. Switch pair daily4. Appropriate workspace layout5. Take a break from working together6. Pair programming is chatting

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

MILAN 20/21.11.2015 - Manuela Munaretto

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.

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

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

MILAN 20/21.11.2015 - Manuela Munaretto

String Calculator: Step 2

Allow the Add method to handle an unknown amount of numbers

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: “1\n2,3” (will equal 6)2. the following input is NOT ok: “1,\n” (not need to

prove it - just clarifying)

MILAN 20/21.11.2015 - Manuela Munaretto

String Calculator: Step 4

Support different delimiters1. 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

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

MILAN 20/21.11.2015 - Manuela Munaretto

String Calculator: Step 6

Numbers bigger than 1000 should be ignored, so adding 2 + 1001 = 2

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

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

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

MILAN 20/21.11.2015 - Manuela Munaretto

Resources

Extreme Programming: A gentle introductionhttp://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/

MILAN 20/21.11.2015 - Manuela Munaretto

Resources

String Calculatorhttp://osherove.com/tdd-kata-1/

MILAN 20/21.11.2015

Manuela Munaretto - @[email protected]

XPeppers

MILAN 20/21.11.2015 - Manuela Munaretto

Leave your feedback on Joind.in!https://m.joind.in/event/codemotion-milan-2015