It's good coding practice to restrict mutability. As the instance variables are never changed we can make them immutable. Even better: Thus the whole class Dinglemouse becomes immutable - an instance of Dinglemouse can never be changed after initialization. As for the parameters it might not be mandatory to declare them final, but I made it a habit to declare all variables final by default, unless for the rare occasion where I really need a mutable variable. Also it is best avoided to change the value of parameters, so declaring them final makes this more explicit.
In the fifth good example you can turn left or right when you get to the first cross, how is that not ambiguous?
Yes. What you say is correct when going from LHS 'X' to the RHS 'X'. The line is ambiguous in that direction. But it is not ambigous traversing the line in the other direction (RHS to LHS).
So the line is valid. Because of the rule "Sometimes a line may be valid in one direction but not the other. Such a line is still considered valid."
I still don't understand what exactly you mean by "ambiguous" then. In the fifth good example you can turn left or right when you get to the first cross, how is that not ambiguous?
You say the first it false because it's ambiguous because you can go the long way or the short way but the short way does not satisfy the rule "Every line "character" found in the grid must be part of the line. If extras are found then the line is not valid." Am I missing something here? This one should be true based on my understanding
Nice kata and crystal clear explanations. Thanks!
Appears very short, but runs the string 52 times instead of the once that is necessary- this is inefficient on a string longer than 26 characters.
It's good coding practice to restrict mutability. As the instance variables are never changed we can make them immutable. Even better: Thus the whole class Dinglemouse becomes immutable - an instance of Dinglemouse can never be changed after initialization. As for the parameters it might not be mandatory to declare them final, but I made it a habit to declare all variables final by default, unless for the rare occasion where I really need a mutable variable. Also it is best avoided to change the value of parameters, so declaring them final makes this more explicit.
Excuse me. why use final in this case?
Original and creative kata. Thanks!!
@reggaeguitar
Yes. What you say is correct when going from LHS 'X' to the RHS 'X'. The line is ambiguous in that direction. But it is not ambigous traversing the line in the other direction (RHS to LHS).
So the line is valid. Because of the rule "Sometimes a line may be valid in one direction but not the other. Such a line is still considered valid."
I still don't understand what exactly you mean by "ambiguous" then. In the fifth good example you can turn left or right when you get to the first cross, how is that not ambiguous?
@reggaeguitar. Does it matter?
If it is false (because ambiguous) or false (because doesn't use every character) then either way it is false, right?
it's NOT 6 kyu kata....
You say the first it false because it's ambiguous because you can go the long way or the short way but the short way does not satisfy the rule "Every line "character" found in the grid must be part of the line. If extras are found then the line is not valid." Am I missing something here? This one should be true based on my understanding
This comment is hidden because it contains spoiler information about the solution
Would be nice if the C# tests used a char[][] as an argument so I didn't have to reimplement Preloaded.MakeGrid. Other than that awesome kata!
at least, got good practice ^_^!
@dinglemouse it is really nice solution to this Kata. I've come up with 70 lines of code comparing to yours 10
This is incorrect synchornization.
totalVisits
also must be synchronized on same monitor thatvisit
method, also this rule must be applied tovisitsBy
methodLoading more items...