Re: Stereo setup for visad

Hi Tim,

> I'm trying to add stereo to visad as was discussed here:  
> http://www.unidata.ucar.edu/staff/russ/visad/msg15790.html
> and I'm having some problems making it work as part 2 of that email 
> indicated, extending FancySSCell and SpreadSheet.
>
> The problem I am having is that the only time you can call super() is on the 
> first line of the constructor.  Therefore, the only time I can call 
> setSSCellClass() is after I call super() in my extension.  However, calls to 
> setSSCellClass() that are performed after the constructor appear to be 
> ignored.  I verified this by directly modifying my copy of SpreadSheet.java 
> to call setSSCellClass() at the very beginning of StereoSSCell's constructor, 
> with my extension of FancySSCell.  When I did this, the code I added to setup 
> stereo was called.  I then put that call on the last line of the constructor, 
> and tried again.  This time my code was not executed (the constructor does 
> not get called).
>
> One possible workaround that I am aware of is simply copying the entire 
> constructor from SpreadSheet.java into my extension of SpreadSheet, but that 
> would obviously not be considered proper OO programming, and I would like to 
> know if there is another way to do it.

Another work-around is to call a super() signature that
has arguments, and to "compute" one of those arguments
by calling a static method of your extension class, that
calls SpreadSheet.setSSCellClass(). That is, your static
method might always return 2 for the number of rows (or
whatever), but before returning 2 call
SpreadSheet.setSSCellClass().

I suspect that Curtis's intention in the SpreadSheet
design was that applications would call
SpreadSheet.setSSCellClass() before calling the
SpreadSheet constructor (or extension class
constructor), something I didn't realize when I
answered Mike Redmond's question about stereo.

As to proper OO programming, my feeling is that it is
important for core system classes to have proper OO
programming so that lots of things can be changed by
extending classes, but that it is not important for
application classes to have neat OO programming. My
motto is sort of "let the system be designed well, so
applications can be easy hacks."

Good luck,
Bill