Hi,
Some time ago, I decided to make an attempt to tackle a
train reservation kata. I found this to be a tricky kata to do using the "tell don't ask" messaging style (for reasons I may elaborate on if anybody is interested) and distributing responsibilities between objects gave me a hard time. Then I remembered that GOOS book had a sample in it that looked exactly like part of the train reservation kata:
public void reserveSeats(ReservationRequest request) {
for (Carriage carriage : carriages) {
if (carriage.hasSeatsAvailableWithin(percentReservedBarrier)) {
request.reserveSeatsIn(carriage);
return;
}
}
request.cannotFindSeats();
}
So my question is: was this sample taken from a piece of code and if so, can I find it anywhere? I tried searching the internet but the only things I could find was this piece of code
with empty collaborators.
If not, maybe you could point me to a solution to this kata that you consider to be the prime example of solving this problem?
Best regards,
grzesiek