How to Create a Wordle with TDD in Javascript
13 September, 2022
12
12
2
Contributors
TL;DR: Javascript is also awesome for TDD
Set-Up
Defining a Word
Mixing (accidental) implementation details with (essential) behavior is a widespread mistake.
Notice
•
•
•
•
•
•
•
•
•
•
Creating a Word
Notice
•
•
•
Few Letters
Notice
•
•
•
•
•
Changing the current implementation
Notice
•
•
•
Checking Too Many Letters
Refactor (or not)
Valid Letters
Notice
•
•
More Invalid
Notice
•
Refactor
Notice
•
•
•
•
Comparing Words
Notice
•
•
More Words
Notice
•
It is very important to check for equality/inequality instead of assertTrue() since many IDEs open a comparison tool based on the objects.
•
This is another reason to use IDEs and never text editors.
Comparing different cases
English Dictionary
Notice
•
We need to make a decision. According to our bijection, there's an external dictionary asserting valid words.
•
We can validate with the dictionary upon word creation. But we want the dictionary to store valid wordle words. No strings.
•
It is an egg-chicken problem.
•
We decide to deal with invalid words in the dictionary and not the Wordle word.
•
We remove the test.
•
We will find a better way in a few moments.
Wordle Game
Creating Game Objects
Words Attempted
Start guessing
Notice
•
Has Lost
Notice
•
We lose the game
We Play by the Dictionary
Notice
•
•
•
•
•
Play to Win
Notice
•
•
•
Correct Word
Notice
•
•
Lost, Won, both?
Letter Positions
Notice
•
•
•
•
Match
Notice
•
Incorrect Positions
Notice
•
Playing with real examples
(You will find more daily examples in the repo)
Playing by the complex rules
Notice
•
•
Conclusions
Try it out!
Next Steps
•
Combine this solution with the AI-Generated
•
Use a real dictionary
•
Change the language and alphabet
•
Change the rules to a different wordle
JavaScript
javascript
refactoring
tdd