SquareBracketAssociates / BuildingApplicationWithSpec2

A book to build user interfaces using the Spec 2.0 framework.
21 stars 12 forks source link

Finish chapter "Most of Spec in one example" #73

Closed koendehondt closed 5 months ago

koendehondt commented 5 months ago

Open issues from https://github.com/SquareBracketAssociates/BuildingApplicationWithSpec2/pull/52:

koendehondt commented 5 months ago
koendehondt commented 5 months ago

In section "Using transmissions" there is a question from Stéphane. I think this section is too short for such an important feature.

The section is short because we have a dedicated chapter on transmissions.

The question from @Ducasse was:

""Esteban"" I do not understand why this is not working. I get an error with the ports. ""Enzo"" I think the error comes from the fact setModel: is called when the presenter is initialized and so there is no selection, thus a nil parameter. I managed to deal with it by adding a nil guard clause in setModel: but I wonder if we could make a "default selection" that would be the first film so that the presenter starts with a film to display details.

Making a default selection would maybe solve the problem in the example code, but it is not a general-purpose solution for the problem. When setting a model of a presenter, the presenter has to cover a possible nil value. I think that is important to state in the book.

So in my opnion, based on building a lot of UIs, the method setModel was implemented incorrectly because it did not take into account that the argument aFilm could be nil. I changed that method and now the code with the transmission works as expected. I added a few sentences to the text to explain why checking for nil is important.

Ducasse commented 5 months ago

Your analysis is correct!