the `drawing_data_agent', which is used by ANY client to indirectly and polymorphically gather drawing data for the SHAPE! deferred class SHAPE feature {NONE} -- Initialization make_with_color (a_color: like color) -- Make with `a_color' as `color'. do color := a_color drawing_data_agent := agent drawing_data ensure color_set: color.same_string (a_color) end feature -- Access drawing_data_agent: FUNCTION [ANY, TUPLE, like drawing_data] -- Data agent for drawing. feature {NONE} -- Implementation drawing_data: TUPLE [name: like name; color: like color] -- Data needed for drawing of Current. do Result := [name, color] end name: STRING -- Object name of Current. deferred end color: STRING -- Color of Current. end Classic Spaceship example A variation of the classic Spaceship example has one or more spaceship objects roaming about a universe filled with other items like rogue asteroids and space stations. What we want is a double-dispatch method for handling encounters (e.g. possible collisions) between two co-variant objects in our make-believe universe. In our example below, the output excursion of our USS Enterprise and USS Excelsior will be: Starship Enterprise changes position from A-001 to A-002. Starship Enterprise takes evasive action, avoiding Asteroid `Rogue 1'! Starship Enterprise changes position from A-002 to A-003. Starship Enterprise takes evasive action, avoiding Asteroid `Rogue 2'! Starship Enterprise beams a science team to Starship Excelsior as they pass! Starship Enterprise changes position from A-003 to A-004. Starship Excelsior changes position from A-003 to A-005. Starship Enterprise takes evasive action, avoiding Asteroid `Rogue 3'! Starship Excelsior is near Space Station Deep Space 9 and is dockable. Starship Enterprise changes position from A-004 to A-005. Starship Enterprise beams a science team to Starship Excelsior as they pass! Starship Enterprise is near Space Station Deep Space 9 and is dockable. Visitor The visitor for the classic Spaceship example also has a double-dispatch mechanism. make -- Allow SPACESHIP objects to visit and move about in a universe. local l_universe: ARRAYED_LIST [SPACE_OBJECT] l_enterprise, l_excelsior: SPACESHIP do create l_enterprise.make_with_name ("Enterprise", "A-001") create l_excelsior.make_with_name ("Excelsior", "A-003") create l_universe.make (0) l_universe.force (l_enterprise) l_universe.force (create {ASTEROID}.make_with_name ("Rogue 1", "A-002")) l_universe.force (create {ASTEROID}.make_with_name ("Rogue 2", "A-003")) l_universe.force (l_excelsior) l_universe.force (create {ASTEROID}.make_with_name ("Rogue 3", "A-004")) l_universe.force (create {SPACESTATION}.make_with_name ("Deep Space 9", "A-005")) visit (l_enterprise, l_universe) l_enterprise.set_position ("A-002") visit (l_enterprise, l_universe) l_enterprise.set_position ("A-003") visit (l_enterprise, l_universe) l_enterprise.set_position ("A-004") l_excelsior.set_position ("A-005") visit (l_enterprise, l_universe) visit (l_excelsior, l_universe) l_enterprise.set_position ("A-005") visit (l_enterprise, l_universe) end feature {NONE} -- Implementation visit (a_object: SPACE_OBJECT; a_universe: ARRAYED_LIST [SPACE_OBJECT]) -- `a_object'