This Code Kata can seem very strange for people born in the nineties.
The goal is to implement a text-based game in which the player walks through dungeons in order to accomplish a task. The basic characteristics of an implementation are as follows:
- the game generates random dungeons as a group of ROOMS and PATHS that join the ROOMS
- the generation does not leave unreachable ROOMS
- the user is presented with the information about the ROOM they are in and the ROOMS reachable directly from the current ROOM
- the user can move from the current ROOM to the directly reachable ROOMS by entering a command
- We do all of the implementation using "TDD, as if you meant it", of course
- Initially, the goal may be simply to get to a given ROOM
- Then, we may start adding attributes to ROOMS; a possible attribute is something that the user can collect, such as diamonds; N diamonds are placed in the dungeon and the game is finished when the user collects all of them; additional attributes can be used to describe the look a ROOM
- When that's done, we can refactor our implementation so that we do not use IF statements
- When that's done, we can refactor our implementation so that we do not use for/while loops
- We can work on the implementation a little bit more to get rid of excessive tabs (let's allow only up to two tabs in the body of a function, per Robert Martin's suggestion)
- We can get better by limiting the number of lines of a function (how about < 5 lines per function?)
- I'm guessing you did all of this with classes and objects; how would you do it with pure functions and no objects?