The TextTyper has a couple bad smells that I'd like to get rid of:
It modifies the iterator (i) when applying tags in the loop
It modifies the displayedText member as it loops. This is critical for keeping track of what's been printed, but it can be cleaned up.
Instead I think we should add a function, SplitForTyping that would take a string and an index. It would return a struct that contains a string for the display text, a string for the hidden text, and a list of outstanding tags (which need to be applied but only if they haven't already been applied). Every loop the TextTyper would simply call this function, and act on the data accordingly.
It might not even be a function, but rather a complete class, and it should be unit tested.
The TextTyper has a couple bad smells that I'd like to get rid of:
displayedText
member as it loops. This is critical for keeping track of what's been printed, but it can be cleaned up.Instead I think we should add a function,
SplitForTyping
that would take a string and an index. It would return a struct that contains a string for the display text, a string for the hidden text, and a list of outstanding tags (which need to be applied but only if they haven't already been applied). Every loop the TextTyper would simply call this function, and act on the data accordingly.It might not even be a function, but rather a complete class, and it should be unit tested.