17
Coding Dojo: String Calculator vienna.rb Dojo#1, Nov. 2013 Peter Kofler, ‘Code Cop’ @codecopkofler www.code-cop.org Copyright Peter Kofler, licensed under CC-BY.

Coding Dojo: String Calculator (2013)

Embed Size (px)

Citation preview

Page 1: Coding Dojo: String Calculator (2013)

Coding Dojo:String Calculator

vienna.rb Dojo#1, Nov. 2013

Peter Kofler, ‘Code Cop’@codecopkofler

www.code-cop.org

Copyright Peter Kofler, licensed under CC-BY.

Page 2: Coding Dojo: String Calculator (2013)

Peter Kofler

• Ph.D. (Appl. Math.)

• Professional SoftwareDeveloper for 14 years

• “fanatic about code quality”

• I help development teams

PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY

Page 3: Coding Dojo: String Calculator (2013)

Expectations?

Page 4: Coding Dojo: String Calculator (2013)

Coding Dojo Mindset

● Safe place outsidework

● We are here to learn● Need to slow down● Focus on doing it right● Collaborative Game

PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY

Page 5: Coding Dojo: String Calculator (2013)

Dojo Structure

● Introduction 15'● Coding 30'● Interim (Retrospective) 15'● Break● Coding 45'● Retrospective 15'

PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY

Page 6: Coding Dojo: String Calculator (2013)

TDD Skills

● Driving Development with Tests ● Designing Test Cases● Designing Clean Code● Refactoring Safely

PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY

Page 7: Coding Dojo: String Calculator (2013)

TDD should be...

● Add a test● See it fail● Add code to make all tests pass● Refactor mercilessly● Repeat

PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY

Page 8: Coding Dojo: String Calculator (2013)

… but often is

● Think up design● Write some tests that verify the design● Write full implementation● Test, debug, test, debug, test, debug, …● Add TODO to refactor later

PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY

Page 9: Coding Dojo: String Calculator (2013)

String Calculator

PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY

Page 10: Coding Dojo: String Calculator (2013)

Requirements

● Create a String calculator (class) with a method Add that accepts a string and returns a number

● The string contains 0, 1, or 2 numbers.● It returns their sum.● An empty string will return 0.● Example inputs are “”, “1”, or “1,2”.

● Start with simplest test (empty string)

PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY

Page 11: Coding Dojo: String Calculator (2013)

Don't Focus on Getting it Done.F0cus on Doing

It Perfectly.

Page 12: Coding Dojo: String Calculator (2013)

→Practice

Page 13: Coding Dojo: String Calculator (2013)

More Requirements

● Now change the Add method to handle an unknown number of arguments (numbers inside string).

● e.g. “1,2,3” should return 6.● Allow the Add method to handle also

new lines between numbers (instead of commas).

● e.g. “1\n2,3” should return 6.

PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY

Page 14: Coding Dojo: String Calculator (2013)

Closing Circle

● What did you learn today?

● What surprised you today?

● What will you do differently in the future?

PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY

Page 15: Coding Dojo: String Calculator (2013)

Global Day of CodeRetreat

#gdcr13

(14.12.2013)http://coderetreat.org/events/global-day-of-coderetreat-vienna-2014

Page 16: Coding Dojo: String Calculator (2013)

Peter Kofler@codecopkofler

www.code-cop.org

Kata by

Roy Osherove@RoyOsherove

http://osherove.com/tdd-kata-1/

PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY

Page 17: Coding Dojo: String Calculator (2013)

CC Images● Dojo http://www.flickr.com/photos/49715404@N00/3267627038/● Todos http://www.flickr.com/photos/kylesteeddesign/3724074594/● Calculator http://www.flickr.com/photos/7271689@N05/2209497074● Wants you http://www.flickr.com/photos/shutter/105497713/

PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY