Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Imperative Bowling Kata - 20 Years On - Delegat...

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.

Imperative Bowling Kata - 20 Years On - Delegating Menial Tasks to Github Copilot Chat - using Scala in IntelliJ IDEA

In this deck we carry out a code kata for the game of Ten Pin Bowling.

While we are going to use Test Driven Development (TDD), we are not going to write any code, and that is because we are going to delegate manual/menial work to Github Copilot.

The tests that we are going to use, and the code that is going to get written, were captured 20 years ago in a deck written by Robert Martin and used by him to demonstrate TDD-based code katas.

While the game is coded using the imperative programming paradigm, Robert Martin used Java, whereas we are going to use Scala.

Keywords: bowling game code kata, code kata, TDD, Refactoring, AI, Github Copilot, Imperative Programming, Robert Martin, Uncle Bob, Scala, IntelliJ IDEA

ERRATUM: 39 premium requests at 4c each are $1.56

Avatar for Philip Schwarz

Philip Schwarz PRO

March 29, 2026
Tweet

More Decks by Philip Schwarz

Other Decks in Programming

Transcript

  1. Imperative Bowling Kata 20 Years On Delegating Menial Tasks to

    Github Copilot Chat using Scala in IntelliJ IDEA @philip_schwarz slides by https://fpilluminated.org/
  2. In this deck we carry out a code kata for

    the game of Ten Pin Bowling. While we are going to use Test Driven Development (TDD), we are not going to write any code, and that is because we are going to delegate manual/menial work to Github Copilot. The tests that we are going to use, and the code that is going to get written, were captured 20 years ago in a deck written by Robert Martin and used by him to demonstrate TDD-based code katas. While the game is coded using the imperative programming paradigm, Robert Martin used Java, whereas we are going to use Scala. @philip_schwarz
  3. Be warned that what follows is just an experiment. There

    is nothing prescriptive / exemplary / recommended about the experiment and about its parameters, e.g. • The programming paradigm used (imperative programming - shudder) • The contents of the copilot-instructions.md file used • The Github Copilot mode used (Agent) • The LLM model used (Claude Sonnet 4.6) • The particular prompts used - e.g. their length, their approach to expressing details, etc. Just because the above parameters had the intended consequences for the limited purpose of re-enacting a classic sample code kata, it doesn’t mean that they are of any particular merit. They were not the results of a planned strategy and/or tactics aimed at securing a desired outcome in terms of e.g. optimality, effectiveness, efficiency, productivity.
  4. † slightly modified – e.g. with some highlighting and some

    annotations Let’s look at Robert Martin’s preamble section: "A Quick Design Session” †.
  5. Bowling Game Kata Object Mentor, Inc. fitnesse.org Copyright © 2005

    by Object Mentor, Inc All copies must retain this page unchanged. www.junit.org www.objectmentor.com blog.objectmentor.com
  6. Scoring Bowling. The game consists of 10 frames as shown

    above. In each frame the player has two opportunities to knock down 10 pins. The score for the frame is the total number of pins knocked down, plus bonuses for strikes and spares. A spare is when the player knocks down all 10 pins in two tries. The bonus for that frame is the number of pins knocked down by the next roll. So in frame 3 above, the score is 10 (the total number knocked down) plus a bonus of 5 (the number of pins knocked down on the next roll.) A strike is when the player knocks down all 10 pins on his first try. The bonus for that frame is the value of the next two balls rolled. In the tenth frame a player who rolls a spare or strike is allowed to roll the extra balls to complete the frame. However no more than three balls can be rolled in tenth frame.
  7. Scoring Bowling. The game consists of 10 frames as shown

    above. In each frame the player has two opportunities to knock down 10 pins. The score for the frame is the total number of pins knocked down, plus bonuses for strikes and spares. A spare is when the player knocks down all 10 pins in two tries. The bonus for that frame is the number of pins knocked down by the next roll. So in frame 3 above, the score is 10 (the total number knocked down) plus a bonus of 5 (the number of pins knocked down on the next roll.) A strike is when the player knocks down all 10 pins on his first try. The bonus for that frame is the value of the next two balls rolled. In the tenth frame a player who rolls a spare or strike is allowed to roll the extra balls to complete the frame. However no more than three balls can be rolled in tenth frame.
  8. Scoring Bowling. The game consists of 10 frames as shown

    above. In each frame the player has two opportunities to knock down 10 pins. The score for the frame is the total number of pins knocked down, plus bonuses for strikes and spares. A spare is when the player knocks down all 10 pins in two tries. The bonus for that frame is the number of pins knocked down by the next roll. So in frame 3 above, the score is 10 (the total number knocked down) plus a bonus of 5 (the number of pins knocked down on the next roll.) A strike is when the player knocks down all 10 pins on his first try. The bonus for that frame is the value of the next two balls rolled. In the tenth frame a player who rolls a spare or strike is allowed to roll the extra balls to complete the frame. However no more than three balls can be rolled in tenth frame.
  9. Scoring Bowling. The game consists of 10 frames as shown

    above. In each frame the player has two opportunities to knock down 10 pins. The score for the frame is the total number of pins knocked down, plus bonuses for strikes and spares. A spare is when the player knocks down all 10 pins in two tries. The bonus for that frame is the number of pins knocked down by the next roll. So in frame 3 above, the score is 10 (the total number knocked down) plus a bonus of 5 (the number of pins knocked down on the next roll.) A strike is when the player knocks down all 10 pins on his first try. The bonus for that frame is the value of the next two balls rolled. In the tenth frame a player who rolls a spare or strike is allowed to roll the extra balls to complete the frame. However no more than three balls can be rolled in tenth frame.
  10. The Requirements. • Write a class named “Game” that has

    two methods – roll(pins : int) is called each time the player rolls a ball. The argument is the number of pins knocked down. – score() : int is called only at the very end of the game. It returns the total score for that game.
  11. The Requirements. • Write a class named “Game” that has

    two methods – roll(pins : int) is called each time the player rolls a ball. The argument is the number of pins knocked down. – score() : int is called only at the very end of the game. It returns the total score for that game. Each pin knocked down adds 1 point to the score
  12. The Requirements. • Write a class named “Game” that has

    two methods – roll(pins : int) is called each time the player rolls a ball. The argument is the number of pins knocked down. – score() : int is called only at the very end of the game. It returns the total score for that game.
  13. A quick design session A frame has 1 or two

    rolls. In each frame the player has two opportunities to knock down 10 pins. The score for the frame is the total number of pins knocked down, plus bonuses for strikes and spares.
  14. A quick design session The tenth frame has two or

    three rolls. It is different from all the other frames.
  15. A quick design session The score function must iterate through

    all the frames, and calculate all their scores.
  16. A quick design session The score for a spare or

    a strike depends on the frame’s successor A spare is when the player knocks down all 10 pins in two tries. The bonus for that frame is the number of pins knocked down by the next roll.
  17. A quick design session The score for a spare or

    a strike depends on the frame’s successor A strike is when the player knocks down all 10 pins on his first try. The bonus for that frame is the value of the next two balls rolled.
  18. The next slide contains links to YouTube videos that •

    may help to reinforce one’s understanding of the game • may appeal to people who prefer video over text
  19. The next two slides show how Copilot was used, on

    the command line, to create the project used for the kata.
  20. Manually deleted these two files after executing the prompt: -

    lightning-talk/src/main/scala/Main.scala - lightning-talk/src/test/scala/ExampleSpec.scala
  21. Finally, a blow by blow account of the code kata

    session, in the form of a sequence of screenshots capturing every TDD step that was taken.
  22. What was the cost of that code kata session, on

    top of the monthly cost of Copilot’s Pro plan?
  23. The cost was $1.60, and was determined by the LLM

    model used and the number of premium requests made. The session captured in the screenshots consisted of 39 premium requests using Claude Sonnet 4.6. See next for examples of the cost of other similar sessions.