next up previous
Next: 3.1.2.0.2 Coding the View Up: 3.1.2 How to Write Previous: 3.1.2 How to Write

3.1.2.0.1 Warning

Most introductory books are written by authors who do not understand the model-view-controller pattern and the proper use of callbacks. Callbacks are not supported in C or C++ because there is no concept of procedures as data objects (simply passing a pointer to a procedure does not work!). As a result, textbook authors with a C/C++ background are accustomed to using ugly alternatives to callbacks which they continue using in Java. A common and particularly onerous abuse of the Java callback interface is implementing the requisite listener interfaces by methods in the main viewer class, which is typically a frame or an applet. This approach limits each event category for the frame or applet to a single callback, e.g., one callback method for all buttons.

This approach has four serious disadvantages.

Since the command pattern (procedures as data objects) completely eliminates this mess, the ``view class as listener'' approach to event processing is indefensible. Nevertheless, it is widely taught in Java textbooks.


next up previous
Next: 3.1.2.0.2 Coding the View Up: 3.1.2 How to Write Previous: 3.1.2 How to Write
Corky Cartwright
2001-08-02