To: wakita at is.titech.ac.jp Cc: lablgtk at kaba.or.jp Subject: Re: reusing button class In-Reply-To: Your message of "Fri, 05 Jan 2001 14:10:09 +0900" <20010105141009H.wakita@is.titech.ac.jp> References: <20010105141009H.wakita at is.titech.ac.jp> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20010105163043J.garrigue at kurims.kyoto-u.ac.jp> Date: Fri, 05 Jan 2001 16:30:43 +0900 From: Jacques Garrigue Lines: 47 From: Ken Wakita > I guess what you favor is object composition or delegation to > inheritance. I agree that delegation is more flexible and sometimes > better for design reuse of the source code. But your code can be > polished by delegating [connect] and [event] message to the [button] > object and remove somewhat misterious code fragments. Yes, yes and yes. I sometimes use too much my knowledge of the internals of the system. > By the way, why do we have [connect] and [event] or why not clicked, > grab_default, and others? The following is the list of methods > [button] class inherits from its ancestors. > > gtkobj: destroy, get_id > widget: as_widget, misc, drag, coerce > container: add, remove, children, set_border_width, focus > button_skel: clicked, grab_default > button: connect, event > > Maybe it's not meaningful to reuse the methods from container as we > have replaced the implementation of container but still we can wire > and replace methods provided by the [container] class with the ones > provided by vertical [box] object. Yes. You might want to add things like set_border_width, clicked or grab_default. I mostly use delegation for rather specific widgets, where there is not very much to report anyway. > By the way, one thing I miss for ocamlbrowser is ability to browse the > class hierarcy. As the current implementation does not show the super > class I am obliged to look into *.ml* files for investing class > organization. Probably this is caused from ocaml not saving this > information in the *.cmi. I agree that is a disturbing problem. I might try to sneak it in the .cmi, while everybody is looking away. Something link a pointer to the parent class, when inheritance is explicit in the interface. Notice however that you can perfectly inherit without saying it in the interface, or write inherit in the interface without actually inheriting. Jacques --------------------------------------------------------------------------- Jacques Garrigue Kyoto University garrigue at kurims.kyoto-u.ac.jp JG