Can I find the full "train/carriage" sample from the book anywhere (and some comments of Train Reservation Kata)?

118 views
Skip to first unread message

Grzegorz Gałęzowski

unread,
Apr 13, 2020, 1:07:19 PM4/13/20
to Growing Object-Oriented Software
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
Reply all
Reply to author
Forward
0 new messages