Module 6 :
Lecture M6S2 : « Hi @sherazade.d. I have a question about the sokoban example with double dispatch (lecture 6.2). I am a little bit confused with the code. We see in the presentation:
GameView >> drawBlock: aBlock on: aCanvas
aBlock drawOn: aCanvas view: self
Wall >> drawOn: aCanvas view: aView
aView drawWall: aCanvas
Is there something missing here? How does aView know where to draw the wall block on aCanvas? Perhaps it should take the block as an argument? Like this:
Wall >> drawOn: aCanvas view: aView
aView drawWall: self on: aCanvas
???
P.S. Guillermo Polito said that double dispatching is doing by blocks and canvases. But this is not true! A canvas is an argument only. A view is the receiver of the message, so view classes are responsible for the dispatching, not canvases! »
Lien du message : https://discord.com/channels/223421264751099906/1244572019190923286/1260153468312748102
Module 6 : Lecture M6S2 : « Hi @sherazade.d. I have a question about the sokoban example with double dispatch (lecture 6.2). I am a little bit confused with the code. We see in the presentation: GameView >> drawBlock: aBlock on: aCanvas aBlock drawOn: aCanvas view: self Wall >> drawOn: aCanvas view: aView aView drawWall: aCanvas Is there something missing here? How does aView know where to draw the wall block on aCanvas? Perhaps it should take the block as an argument? Like this: Wall >> drawOn: aCanvas view: aView aView drawWall: self on: aCanvas ??? P.S. Guillermo Polito said that double dispatching is doing by blocks and canvases. But this is not true! A canvas is an argument only. A view is the receiver of the message, so view classes are responsible for the dispatching, not canvases! » Lien du message : https://discord.com/channels/223421264751099906/1244572019190923286/1260153468312748102