[Insight-developers] Modes versus Objects

Bill Lorensen bill.lorensen at gmail.com
Thu Jun 2 11:32:27 EDT 2011


Folks,

This discussion is motivated by recent activity...

Back in the early days of OO programming, I recall having discussions
about the use of modes versus objects. When I taught OO courses I
always discouraged modes if they changed the "identity" of the object.

Should a mode be used to change the behaviour of an object or should a
new object be created?

A case where a mode is better than an object:
Controlling the visibility of an actor in VTK:
  1) Mode: vtkActor VisibilityOn/Off
or
  2) Object: two classes vtkActor and vtkVisibleActor

  1) is the appropriate solution since, at run time, an application
may want to change the visibility of an actor.

A case where an object may be better than a mode:
  1) Mode: itkShiftScaleImageFilter
SetOperationOrderToShiftScale()/SetOperationOrderToScaleShift()
or
  2) Object: two classes itkShiftScaleImageFilter and itkScaleShiftImageFilter

 A VTK approach versus an ITK approach
  1) mode: vtkImageMathematics 21 different modes (ADD,SUBTRACT,MULTIPLY,...)
  2) object: itkAddImageFilter, itkSubtractImageFilter,
itkMultipleImageFilter...

It is not always obvious as to the best choice. But, I think the
question should be asked anytimne we introduce a new "mode".

Bill


More information about the Insight-developers mailing list