S01E05: [TDD 🍅 4] Swift Mutation Testing and Refactoring
This is not the result you’re looking for 👋
In this session, we’ll decide how we’ll route to the quiz result. So, what is a Result? The result is an accumulation of the questions and answers. This way we can assess the user’s score or show them which questions they answered correctly.
Perhaps that could look something like this:
protocol Router {
...
func routeTo(result: Result)
}
Discussion: do we need to create a custom data structure or is there a Foundation data structure that will work for our use case?
Let’s consider a couple of our options…
Dictionary:
- Cannot contain duplicate questions (if the question is the key)
- Will be unordered
- Needs to be hashable (to guarantee uniqueness)
Array:
- Can contain duplicate questions
- Will be ordered
For our purpose, it seems that a dictionary data structure makes the most sense. We don’t care about order and there doesn’t appear to be a reason for a quiz to contain two or more of the…