I have some questions concerning the definition of the FSMs for Exercise 4:
In the HasNextMonitorTemplate class, I think the regular expression
mirrors the "FailSafeIter" contract.<code>create(c,i) update(c)* iter(i)+ update(c)+ iter(i)</code>
Furthermore - concerning the same class - I'm confused why we allow for an unchecked "next" operation from the initial to the middle state. I understand that - in the general case - this state represents the situation when we have called "hasNext" and are therefore sure to be able to call "next", but when we start the iterator we did not necessarily call "hasNext" which would fail if the collection being iterated over is empty.
And why do we allow the machine to return from the error state?Code: Alles auswählen
initial.addTransition(getSymbolByLabel(Next), middle);
This goes against my intuition, that we cannot make an unchecked "next" undone by calling the "hasNext" method afterwards, especially becauseCode: Alles auswählen
error.addTransition(getSymbolByLabel(HasNext), initial);
we may have looped in the error state due to several "next" events.
Best regards
Roland