[vtkusers] an source code refactoring idea
Xiaofeng Zhao
xf10036 at hotmail.com
Tue Aug 7 21:18:14 EDT 2007
VTK uses a lot of bi-directional navigatability among the classes. For
example, from vtkRenderWindow once can reach each of vtkRenderers and vice
versa. When used in a well architected system, such as in VTK,
bi-directional navigatablity by itself is not neccesary evil. However, the
power of a tool kit such as VTK is in its extendablity by users. And for
this, bi-directional navigatable association should be avoided, because
putting the power of hooping from class to class and a programmer that's not
well versed in OOD together tend to produce a disasterously entangled mess.
I recently took a close look at the structural relationship of the VTK
classes and made an attempt to optimized the association between
vtkRenderWindow class and vtkRenderer class. Considering that
vtkRenderer's are deligated to do the rendering, it's reasonable to decide
that vtkRenderer does not need to have full access to vtkRenderWindow.
After playing for a while, I came out a slightly different association: 1.
The vtkRenderer carries a reference to vtkWindow, which is a base class of
vtkRenderWidnow. 2. move these properties of the display window that
vtkRenderer in bona fide need for performing the rendering job from
vtkRenderWindow to vtkWindow.
The above change may not the be optimal but can be a good starting point to
further rationalize the structural relationships of the vtk classes because
with the above change, the other part of the entire VTK library requires
surprisingly little change to compile and build.
Xiaofeng Zhao
More information about the vtkusers
mailing list