Intermediate Object-Oriented Programming (OOP) Katas

21 Mar 2024
Once basic concepts such as conditionals, loops, and simple structures have been introduced and reinforced, and TDD has been strictly practiced, it's time to add complexity and begin with OOP as well as other testing concepts such as test doubles, different TDD styles, and how to approach a problem with both examples.

Katas

Text processing: In this kata, the concept of DTO is taught, where the goal is not to be tied to the output displayed on the screen but to the information that truly matters. It also aims to work on a task iteratively and incrementally. Do not focus on graphical representation.

Bags: Kata to work on data structures, OOP, and polymorphism.

PrintDate: Kata to work on collaborators, test doubles, and the theory of what type of double would be a [Command] and what type of double would be a [Query].

Iteration 1: Use test doubles and understand "Don’t Mock What You Don’t Own" - Optional, use CRC cards
Iteration 2: Create your own test doubles

Tic tac toe: Kata designed to learn 2 important things:

Iteration 1: TDD inside-out, see how tests evolve and work on how it should be done, separating [Commands] and [Queries], or the game could return its state.
Iteration 2: TDD outside-in without coupling to graphical representation, this part will be worked on in the Bank kata (although if someone finishes early, they can try to see how to implement it)
Iteration 3: Application of object calisthenic and use mutant testing to help create stronger tests.

Smart Fridge:
Iteration 1: TDD inside-out (introduction to collaborators)
Iteration 2: TDD outside-in (only make the contract test with test doubles)
Iteration 3: Application of object calisthenic

Guess the random number: Kata to learn 3 things:
Iteration 1: TDD inside-out (introduction to collaborators)
Iteration 2: TDD outside-in (only make the contract test with test doubles)
Iteration 3: TDD outside-in making the contract and with this contract create collaborators using TDD, This could be done with a double loop doing ATDD.

ATM machine: Incremental iterative kata that has state and can be approached from inside-out or outside-in.
Iteration 1: Choose the style you think you should work on more.
Iteration 2: Do it in the style you feel most comfortable with.
Iteration 3: Application of object calisthenic

Shopping cart: Incremental iterative kata that has state and can be approached from inside-out or outside-in.
Iteration 1: Choose the style you think you should work on more. - Optional, use CRC cards
Iteration 2: Do it in the style you feel most comfortable with.
Iteration 3: Application of object calisthenic

Bank: Kata designed to work on it with outside-in and using ATDD.
Iteration 1: TDD outside-in
Iteration 2: BDD with Gherkin or Cucumber

Salary slip kata: Kata designed to work with OOP and BDD.
Iteration 1: Work on outside-in and using ATDD
Iteration 2: Work on inside-out
Iteration 3: Work on BDD. Focus on learning what BDD is, how a correct feature would be, set up the language you need, and invest the necessary time.

Conway's Game of Life:
Iteration 1: TDD inside-out (introduction to collaborators)
Iteration 2: TDD outside-in (only make the contract test with test doubles)

Tips:

Take advantage of learning how to pivot from inside out and from outside in, depending on what you need. Depending on what you try to implement, think about which layer of the test pyramid you should start with.

Learnings:


Test pyramid
Collaborative work
Software design principles
Testing strategies
              Test doubles
               What are they?
               What types exist?
               When to use them?
                How to create your own test doubles? Don’t Mock What You Don’t Own

DTO and Value Objects
Avoid working with primitives
Law of Demeter

 

 

Tell us about your challenges by clicking on the banner