The DictionaryReplacer Kata
This kata is about making a simple string replacer. It is inspired by Corey Haines Lightning talk about practicing. Create a method that takes a string and a dictionary, and replaces every key in the dictionary pre and suffixed with a dollar sign, with the corresponding value from the Dictionary.
input: “”, dictionary: empty, output: “”
input: “$temp$”, dictionary: [“temp”, “temporary”], output: “temporary”
input: “$temp$ here comes the name $name$”, dictionary: [“temp”, “temporary”] [“name”, “John Doe”], output: “temporary here comes the name John Doe”
Duration: Ca. 5-20 Minutes
Preperations for the start
The following is required for the project:
- Node.js (runs on Windows, Mac and Linux)
npm install typescript –gin the terminal
- Visual Studio Code (runs on Windows, Mac and Linux)
There has already been deposited a complete exercise project on GitHub for you:
git clone https://github.com/GregorBiswanger/KataDictionaryReplacer.git
Then install all necessary modules within the project with
- Open the project with Visual Studio Code
- Start the TypeScript compiler with the key combination
[ctrl] + [shift] + [b]
- At the terminal, write
npm testwithin your project
Now the testrunner Jasmine is running. It notices file changes automatically. If you have a second monitor, there is the ideal place for the terminal. This allows you to observe the current status during development.
Important with Coding Dojos is, to solve every task step by step. This principle is not easy for many developers. But exactly this is, what coding dojos are teaching us.
Which tasks have to be performed step by step can be found in the
spec directory. The actual programming takes place in the
The project already has all the necessary Visual Studio Code settings, so you can easily debug within the tests or your own code. Simply set the breakpoint with the
[F9]-key and start the debugging with
- Solve the kata until all tests are green
- Then copy your solution here on jsfiddle.net:
- Click on the “Update” button in the upper left corner and comment on your link here at this blog post
- Not till then, you are allowed to compare your solution with already commented solutions
Let’s get ready to rumble!