I did a workshop about TDD at work and for preparation I browsed the internet looking for a fitting assignment, and I came across TDD in Unity - Part 1 by Charles Amat, where he sets up his assignment: implementing the Life Gauge from Zelda: Breath of the Wild game.
I thought this assignment was fitting for the workshop, thus I read the Life Gauge page on the Zelda wiki (which was linked in the 'Part 1' post), and also played the game a bit, focusing on the Life Gauge behavior. But I did not go through the 'TDD in Unity' series, as I was running out of preparation time.
My focus and task order in both my preparations and workshop were:
I only had time prepare the first couple of domain logic requirements and during the workshop we collaboratively completed those together before the time was up.
After the workshop I was curious how Charles Amat solved it, thus I watched the whole TDD in Unity series. I both enjoyed and learned from watching Charles Amat live coding and implementing the Life Gauge and his end result solution is good and sound, and I thank Charles for his contribution. But I noticed that his focus and task order quite differed from mine, as he:
This is why I think it's worth doing another series with the same assignment, but with my focus, task order, and format.
My format will be blog posts focused on the TDD cycles displaying the appropriate code for each step. I'll demonstrate how the requirements and the cycles guide and shape the code and my reasoning, that will read like poetry of rhythmic RED GREEN REFACTOR loops (at least that's my ambition).
The below list is user perspective behaviour summary from the Life Gauge page on the Zelda Wiki for the Breath of the Wild game. I've simplified some requirements to keep the scope within a sensible limit. I've also provided more detail where needed by playing and observing the game. (In real 'gameplay in development' scenario it's important to get the needed details of the requirements as early as possible from the game designer).
Domain Model | View / GUI |
---|---|
(Avatar) Health | Life Gauge |
TBD later | Heart (holds 4 Fractions) |
Points | Heart Fractions |
This mapping is good to start on early: The Heart Container (with its Hearts and fractions) is a specific view representation of the Avatar Health, the domain model. This is a good start of separating the concerns and I'll break them further down below.
I'll apply the approach in the Boundary layer section, making sure that the code dependency is minimal and one-way:
Thus when future change requests on the GUI arrive (which is likely in a real scenario) it will be effortless to handle as both the domain and its logic, and the model naming and terms, will remain unaffected. This also makes it effortless to display simultaneously more than one GUI representations
of the same model (which is quite common in game UI).