Home Segments Index Top Previous Next

664: Mainline

The createViews definition contains an unnecessary substitute for self and no cascades so that the identity of the receivers is clear. An experienced Smalltalk programmer might write createViews as follows, employing self, exploiting the values of assignment expressions, and using cascades liberally:

CalorieViewManager method definition • instance 
createViews 
  | theTopPane theMeterPane | 
  self addView: (theTopPane := TopPane new). 
  theMeterPane := MeterGraphPane new. 
  "Set up the top pane" 
  theTopPane owner: self;  
    labelWithoutPrefix: 'Demonstration Window';  
    noSmalltalkMenuBar;  
    framingRatio: (1/4 @ (3/8) rightBottom: 3/4 @ (5/8)).        
  "Set up the meter pane" 
  theTopPane addSubpane: theMeterPane. 
  theMeterPane owner: self; 
    noScrollBars;  
    framingRatio: (0 @ 0 rightBottom: 1 @ 1);  
    when: #display perform: #callDrawMeter:.