Coding Dojo
Salzburg Software Craftmanship
Also on https://www.softwerkskammer.org/groups/salzburg
What is a Coding Dojo?
• Safe place outside of work and away from
production code
• Deliberate Practice => Learning
• Relax and Slow down
• You don't have to finish
• Focus on doing it right
The Rules
• Test Driven Development
• Pair Programming
• “London” Constraint*



*) London School TDD is Outside-In but Classic TDD can be as well
• Credits to Peter “CodeCop" Kofler 

https://www.slideshare.net/pkofler/coding-dojo-bank-ocr-outsidein-2015
Outside-In TDD
• build the system from the "outside-in", following the
user interaction through all the parts of the system
• (maybe) create a Guiding Test
• start with top level interactions/collaborators
• create fake dependencies or mock them
• implement using TDD until all tests green
• move "inside" to previously faked collaborator
Assignment: Bank OCR
• You work for a bank, which has a machine to assist in reading
letters. The machine scans the paper documents, and produces a
file with a number of entries which each look like this:
• ····_··_·····_··_··_··_··_· 

··|·_|·_||_||_·|_···||_||_| 

··||_··_|··|·_||_|··||_|·_|
• Each entry is 4 lines long, each line has 27 characters. The first 3
lines contain an account number written using pipes and
underscores, and the fourth line is blank. Each account number
should have 9 digits, all of which should be in the range 1-9.
• Write a program that can take this file and parse it into actual
account numbers
Prepare
• Find a pair
• Choose a programming language
• Find samples: https://bitbucket.org/pkofler/
bankocr-kata-setup/ -> src/test/resources
• http://codingdojo.org/kata/BankOCR/

Use Case 1
• Work through outer API
Guiding Test
public class GuidingTest {
@Test
public void shouldParseOcrLine() throws IOException {
// TODO failing test, start here
// guiding test from outside in as starting point.
// a) ignore this test
// b) or stub everything in the BankOcr constructor
// c) or let it be red until the end
BankOcr bankOcr = new BankOcr();
List<AccountNumber> accountNumbers = bankOcr.parse(allDigits());
assertEquals(1, accountNumbers.size());
assertEquals(new AccountNumber("123456789"), accountNumbers.get(0));
}
}

Bank OCR Coding Dojo

  • 1.
    Coding Dojo Salzburg SoftwareCraftmanship Also on https://www.softwerkskammer.org/groups/salzburg
  • 2.
    What is aCoding Dojo? • Safe place outside of work and away from production code • Deliberate Practice => Learning • Relax and Slow down • You don't have to finish • Focus on doing it right
  • 3.
    The Rules • TestDriven Development • Pair Programming • “London” Constraint*
 
 *) London School TDD is Outside-In but Classic TDD can be as well • Credits to Peter “CodeCop" Kofler 
 https://www.slideshare.net/pkofler/coding-dojo-bank-ocr-outsidein-2015
  • 4.
    Outside-In TDD • buildthe system from the "outside-in", following the user interaction through all the parts of the system • (maybe) create a Guiding Test • start with top level interactions/collaborators • create fake dependencies or mock them • implement using TDD until all tests green • move "inside" to previously faked collaborator
  • 5.
    Assignment: Bank OCR •You work for a bank, which has a machine to assist in reading letters. The machine scans the paper documents, and produces a file with a number of entries which each look like this: • ····_··_·····_··_··_··_··_· 
 ··|·_|·_||_||_·|_···||_||_| 
 ··||_··_|··|·_||_|··||_|·_| • Each entry is 4 lines long, each line has 27 characters. The first 3 lines contain an account number written using pipes and underscores, and the fourth line is blank. Each account number should have 9 digits, all of which should be in the range 1-9. • Write a program that can take this file and parse it into actual account numbers
  • 6.
    Prepare • Find apair • Choose a programming language • Find samples: https://bitbucket.org/pkofler/ bankocr-kata-setup/ -> src/test/resources • http://codingdojo.org/kata/BankOCR/
 Use Case 1 • Work through outer API
  • 7.
    Guiding Test public classGuidingTest { @Test public void shouldParseOcrLine() throws IOException { // TODO failing test, start here // guiding test from outside in as starting point. // a) ignore this test // b) or stub everything in the BankOcr constructor // c) or let it be red until the end BankOcr bankOcr = new BankOcr(); List<AccountNumber> accountNumbers = bankOcr.parse(allDigits()); assertEquals(1, accountNumbers.size()); assertEquals(new AccountNumber("123456789"), accountNumbers.get(0)); } }