Using variables
In this section, you will learn how to use VA Smalltalk variables, a special kind of part that is useful for sharing objects between views. A variable isn't really an object itself; instead, it is placeholder for another object. You create the real object instance somewhere else in your application and use the variable to refer to the real object.
This can be a useful technique for maintaining model-view separation. Model-view separation is a design technique that keeps an object separate from a view (window) on that object. This allows an object to have multiple views while enhancing reuse and maintainability.
VA Smalltalk is well suited to this technique. You have already seen it in action to some degree through connecting user interface (visual) parts to attributes of the Runner part. The Runner part itself has no knowledge of what the view (or window) looks like.
You will construct a new part, RunnerDataView, containing a variable and then modify the RoadRaceView visual part (as built in Using Object Factories) to use the variable passed by the runner data part.
You will see in the following examples that a variable, acting as a placeholder for an object, can be used to pass an object as a parameter to another view. In particular, you will use a variable as a placeholder for an instance of a runner that will be accessed by another view. When you finish, you will have two simple visual parts that pass a variable between them. The completed visual parts will look like the following in the Composition Editor:
Visual parts
Last modified date: 07/16/2020