SquareBracketAssociates / BuildingApplicationWithSpec2

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

In chapter list, table introduce a simple method to avoid to have Smalltalk globals all classes #99

Closed Ducasse closed 4 months ago

Ducasse commented 4 months ago

Or use

self class environment allClasses

koendehondt commented 4 months ago

This issue has been created to record this comment: https://github.com/SquareBracketAssociates/BuildingApplicationWithSpec2/pull/98#issuecomment-2118981326

I understand the reasoning, but Smalltalk globals allClasses is part of standalone code snippets. They are not part of a class. Therefore, we cannot introduce a method that answers self class environment allClasses.

In the chapter, we could write Object environment allClasses, e.g.

SpListPresenter new
   items: Object environment allClasses;
   open

but doesn't that look strange?

In the code repo, each code snippet from the chapter is a separate method in the class ListTableAndTreeExamples, so there we can easily introduce a new method.

ListTableAndTreeExamples class >> allClasses

   ^ self environment allClasses

so that we can adapt the code in the repo and write this in the chapter:

ListTableAndTreeExamples class >> exampleListWithClasses

   SpListPresenter new
      items: self allClasses;
      open

That is probably the cleanest solution. And we have a one-to-one link between the snippets in the chapter and the methods in the code repo. @Ducasse wdyt?

koendehondt commented 4 months ago

@Ducasse I saw your change in https://github.com/SquareBracketAssociates/BuildingApplicationWithSpec2/commit/ec4e830bad3b26b7d4dab27bcd11e90a93f2ac93. Very good.

koendehondt commented 4 months ago
koendehondt commented 4 months ago

@Ducasse See https://github.com/SquareBracketAssociates/BuildingApplicationWithSpec2/commit/26e51bacd4b51b5e3dffe4d095c89f2682b4bd21, https://github.com/SquareBracketAssociates/BuildingApplicationWithSpec2/commit/c0fa013c236eb140103eebd3f16de720645229de, and https://github.com/SquareBracketAssociates/BuildingApplicationWithSpec2/commit/7fe783972f5b41fff556904e39bd4b8f3c9de98e for additional changes required after displaying the Collection classes. I also removed another reference to Smalltalk.

koendehondt commented 4 months ago

@Ducasse Please close this issue if the changes solve the issue.

Ducasse commented 4 months ago

Thanks I was running out of time as usual :) I thought that I'm not that the code will deterministically return always the same list of class (between different images) so this is why I was not redoing the screenshots. But now you did it so this is great. I really want to remove all the occurrences of Smalltalk in Pharo :)

koendehondt commented 4 months ago

In a recent commit, I took out the last reference from the code snippets. The word Smalltalk is now only visible in "Dolphin Smalltalk" in the introduction.

Ducasse commented 4 months ago

Excellent!