The Bowling Kata Challenge Solution

"Have you ever noticed how many IFs have been used in Bob Martin's Bowling Kata solution? "Is this an effective solution from an evolutionary design perspective?" Damir, a participant of our "You & Me Tech Mentoring" asked Francesco Cirillo how he would have developed that same kata in TDD and without no IFs. In this Challenge, Francesco shows his solution.

This Challenge is available in the following formats:

Video Course Basic - Access to all video modules, final source code and updates €275.00/yearly access Soon
Video Course Premium - Everything in the Basic Subscription, plus: full source code for each module, private Discord Community and detailed programming screenshots. €575.00/yearly access Soon
Coaching Private Guided Tour - Only for the Premium Subscription: 2 hours of 1-on-1 coaching with Francesco monthly: get direct feedback or discuss your design solutions. €300.00 Soon
Live Online Course 4 x 2-hour sessions (max 8 participants) €650.00 Buy

* Price excludes VAT


About this Challenge

The Bowling Kata Challenge is a Course in which Francesco Cirillo, develops one or more features of an application that can calculate the score of a bowling match. Francesco demonstrates how he makes software design decisions, applies principles and tools, his choices of one pattern over another, and his preferences of certain practices.

Course Info

Format
Live: 4x2 hour sessions (max 8 participants) over two weeks.
Video: 30 breakdown sessions for a total of 8 hours.

Language
English

Delivery Options
Live online, onsite, in-house, recorded video.

Trainer
Francesco Cirillo


IS THIS TRAINING FOR YOU?

This Course is ideal for Software Developers and Technical Coaches.

WHAT DO YOU NEED FOR YOUR TRAINING?

No previous knowledge is needed. Much passion is required!

It is strongly recommended to watch the video Three Bowling Kata Solutions"

JOIN THE CONVERSATION

Are you interested in asking questions, clarify specific aspects of the Challenge, or share your solution? The Bowling Kata Community is the place for you.

CERTIFICATE OF ATTENDANCE

This Certificate is delivered to all the participants who have attended the four sessions of the online course.

Objectives

As a result of this course, you will learn to:

  • Develop the initial requirements presented by Bob Martin.
  • Develop the requests proposed by Matteo Vaccari.
  • Develop some other requirements that we can't even imagine right now.
  • Apply test-driven development (TDD)
  • Grow software by applying emergent design techniques.
  • Use product and process metrics to assess the effectiveness of software design.
  • Distinguish User Stories, Scenarios and Requirements and learn how to apply them.
  • Replace the "IF Strategy" with more effective design strategies capable of reducing the complexity of the software system and favour its change and evolution.

The Story Behind this Challenge

Francesco Cirillo tells the story behind the Bowling Kata Anti-If Challenge.

"This Challenge was born out of a request from Damir, one of the participants in the Software Production You and Me Mentoring Programme. One day, he asked me: 'I would like to see how you would develop the Bowling Kata without IFs.'

I admit that I did not know of the Bowling Kata. This Kata is about developing an application that can calculate the score of a bowling match. Robert Martin provided a solution in 2005 to demonstrate how he applies TDD. Robert Martin's solution is considered by many as a 'procedural solution.' The result of applying the 'IF Strategy' several times to deal with new tests. I understand the reason for Damir's request.

	public int score() {
		int score = 0;
		int frameIndex = 0;
		for (int frame = 0; frame < 10; frame++) {
			int frameIndex = 0;
IF=>		if (isStrike(frameIndex)) {
			score += 10 + strikeBonus(frameIndex);
			frameIndex++;
IF=>		} else if (isSpare(frameIndex)) {
      				score += 10 + spareBonus(frameIndex);
					frameIndex += 2;
IF=>		} else {
					score += sumOfBallsInFrame(frameIndex);
					frameIndex += 2;
      		}
      	}
      	return score;
      }
      

I do a bit of Googling to see alternative solutions:

  • Most of the solutions repeat Martin's steps and generate the procedural solution.
  • Several people are surprised by the absence of an abstraction that emerged through his TDD solution and propose the introduction of a Frame class.
  • Matteo Vaccari and Antonio Carpentieri in their "Open/Closed Principle Dojo" propose a number of new interesting user stories (ie 20 frames instead of 10, 3 rolls per frame instead of 2 and other interesting stories). They show the IF tangle that Martin's solution would become by implementing those stories in continuing Martin's way of doing TDD.
	public int score() {
		int score = 0;
        int currentRoll = 0;
        int numFrames = isMartian() ? 12 : (isVenusian() ? 11: 10);
		for (int frame = 0; frame < numFrames; frame++) {
IF=>		if (callistoVariant() && isLastFrame(frame) {
        		while(isStrike(currentRoll, frame)) {
                	score += 10 + sumOfTwoRolls(currentRolls+1);
                    currentRoll++;
                }
IF=>		} else {
IF=>            if(isStrike(currentRoll)) {
                	score += 10 + sumOfTwoRolls(currentRolls + 1);
                    currentRoll++;
                }
            }
IF=>		} if (isSpare(currentRoll)) {
      			score += 10 + rolls[currentRolls+1];
				currentRoll += 2;
IF=>		} else if (isMartian() {
				score += sumOfThreeRolls(currentRolls);
				currentRoll += 3;
IF=>		} else {
				score = sumOfTwoRolls(currentRolls);
				currentRoll += 2;
			}
		}
      	return score;
      }
      
	public boolean isStrike(int currentRoll, int frame) {
IF=>	if (isVenusian()) {
			return rolls[currentRoll] == frame;
		}
		return rolls[currentRoll] == 10;
	}

Note

In the comments of this Blog Post you can find the design solution that Matteo seems to suggest: an implementation of the Chain of Responsibility Design Pattern.


Nicole Lemke

Software Manager, 4flow AG

If you not only want to know what “Object-Oriented Programming” means, but are also interested in its origins and what it can achieve, start here, at the very beginning. Let Francesco take you on a journey. Learn about the essence of good objects and write good stories that those objects can tell.


Course Content

This Challenge is organized in four parts.


PART 01 - Development of the Original Kata

Let's start with the analysis of the problem defined by the Kata.

  • Introduction of the original Kata proposed by Bob Martin.
  • Presentation of the User Stories, Scenarios and Requirements
  • Definition of criteria to evaluate the effectiveness of software design.
  • Development of Bob Martin's original Kata in Test-Driven Development (TDD), one scenario at a time.
  • Assessment of the result achieved in terms of design. What abstractions emerged? Was the TDD effective?

PART 02 - Delivery of the Original Kata

Bowling Kata done!

  • Development and delivery of Bob Martin's original Kata.
  • The evolution of our design so far. Has TDD been effective? Why?
  • Assessment of the design emerged one test at a time.

PART 03 - Development of New Requests

Embrace Change!

  • Presentation of the new requests defined in the Open/Closed Principle Dojo by Matteo Vaccari and Antonio Carpentieri.
  • Writing of the User Stories, Scenarios and Requirements related to the new requests.
  • Development and delivery of the new User Stories.
  • Assessment of the design emerged so far. How much did it cost to deliver those Stories? Had the current system helped us?

PART 04 - Let's Unleash our Imagination

Let's come up with new requests!

  • Presentation of requests taken from the community "The Bowling Kata Challenge"
  • Writing of the User Stories, Scenarios and Requirements related to the new requests.
  • Development and delivery of the new User Stories.
  • Assessment of the design emerged so far. How much did it cost to deliver those Stories? Were we able to reduce the cost of change in our Bowling Kata? Is our software design "simple"? How can we define "simple"?

The Bowling Kata: defusing the "IF Strategy"

Subscribe to the Bowling Challenge Video Stream


About the Trainer

Francesco Cirillo

Francesco Cirillo has worked at the forefront of the software industry for more than 30 years. In a career spanning startups, corporations and freelance consulting, he has mentored thousands of professionals, developers, managers and software teams.

In the 1990s he worked as a Senior Consultant and Mentor for Sun Microsystem, expert in Software Architectures and Software Development Processes and Java and Object-Oriented Evangelist.

Francesco is one of the pioneers of Agile Methods. He started working on XP and TDD in 1999. He was chosen by Kent Beck to develop the XP community in Europe and as reviewer of the second edition of the book Extreme Programming Explained. In 2000 he created XPLabs, the first company in Europe to offer comprehensive services on XP: software development, training and consulting.

In 2007 he created the Anti-IF Campaign to raise awareness in the international community of software developers to apply good design principles to grow software in a sustainable way.

Since 2008 Francesco stopped actively working on Agile Methods and started to develop RRP, a new method of software development. In 2013 he created Cirillo Consulting based in Berlin to offer professional training and consulting on productivity and software development.

Francesco invented the Pomodoro® Technique, a renowned time-management method used by millions of people all over the world, while being a university student looking for a way to get more done in less time.

Read the Francesco Cirillo's complete profile.


Carlo Garatti

Software Engineer, Oracle

If your question is about how to write valuable software, this program is for you!! Through one-on-one lessons with Francesco you will learn how to fit the right techniques and tools in the exact phases of the software development cycle. You will fix and apply these ideas in real cases. And, last but not least, in an enjoyable way!


Price & Conditions

Video Basic

€275.00/YEAR

Learn at your own pace.

  • All 30 modules
    As they're released.
  • Final Source Code
  • All Basic Updates Forever

Video Premium

€575.00/YEAR

Everything in the Basic Subscription, plus:

  • Full Source Code
    You'll get the source code for each module.
  • Access to the Private Discord Community
    Ask questions and discuss the Kata solutions with the Bowling Kata Community

Private Guided Tour

€300.00

Only for the Premium Subscription:

  • Private Coaching
    2 hours of 1-on-1 coaching with Francesco monthly: get direct feedback or discuss your design solutions.

Live Online Course

€650.00

Learn by interaction:

  • 4 x 2-hour sessions over 2 weeks.
  • Small classes, max 8 participants.
  • Free access to our Bowling Kata Community.

Please read our terms and conditions for training courses here.


Marco Isella

Software Engineer

Francesco has changed the way I work, and more.


Upcoming Sessions

At the moment there are no upcoming sessions scheduled. If you are interested in a session, please contact us.


Useful Resources

Three Bowling Kata Reviews

Learn software design by comparing, fixing and expanding three Bowling Kata solutions. In this session, Francesco Cirillo reviews three different...

The Bowling Kata Challenge Solution

Have you ever noticed how many IFs have been used in Bob Martin's Bowling Kata solution? "Is this an effective...

The Anti-IF Workshop

Learn how to replace the 'IF Strategy' with more effective design strategies that will enable you to reduce the complexity...


FAQ

Do you have a question not listed here?

Pomodoro® Web App

The Pomodoro® Timer Web App will be your time tutor and help you stay focused so you can get more...

Pomodoro® Sheets

To help you get started, check out the official templates of the Pomodoro Technique that you can download and print....

Pomodoro® Training Programme

Interruptions and procrastination are one of the most dangerous productivity killers. How to deal with the Predator while we're working...