Path: utzoo!censor!geac!jtsv16!uunet!tut.cis.ohio-state.edu!bloom-beacon!NUSVM.BITNET!ISSLCK From: ISSLCK@NUSVM.BITNET (Law Chee Keong) Newsgroups: comp.windows.x Subject: SUBCLASSING THE ATHENA WIDGETS Message-ID: <8908051732.AA16658@expo.lcs.mit.edu> Date: 5 Aug 89 17:53:39 GMT Organization: The Internet Lines: 38 In reply to Carl Witty's question: I think this has to do with the one of the oldest problems in toolkit design, ie. how do you achieve separation between display and input? Smalltalk's MVC model is an interesting approach, as it separates the display and input processing code into two objects, the view and controller portions, respectively. The X toolkit's notion of widgets on the other hand, combines the view and controller code together inside a widget. The two approaches have their own pros and cons. Hence, someone who wishes to subclass new widgets in the X toolkit may not have a very clear choice of which class to subclass from. Carl's problem is a good illustration of such a problem. This is also a good illustration of the numerous design choices available with an object-oriented approach. For example, InterViews also adopts an object oriented approach, but instead of organizing classes around widgets, they have several other interactor objects available to render the graphics of the toolkit objects. Okay, what am I trying to say? Object Oriented design techniques have made user interface code much more reusable - but it will not solve all your problems, especially if we are dealing with single inheritance. Very often, designers are forced to make difficult choices like which class to subclass from, and just exactly which functions and attributes to bundle into a class and which to abstract. (genericity vs. inheritance) Now, to answer Carl's question. I guess it is inevitable that you have to repeat some of the display code from the command widget. There is simply no clean way to avoid it if you simply want to subclass from an existing widget. Of the two choices you mentioned, I prefer subclassing from the Command widget since you need to write less code with this method, because you very nearly copy most of the existing code from the Command widget. Hope this is of use. C.K. Law Institute of Systems Science Singapore