Hi Petr,

I'm actually defining a subclass of ComboBox, so I am inheriting from that
class. The problem is that the ComboBox constructor does some stuff I don't
want done, but also calls its own superclass constructor (the constructor
for AbstractSelectBox), which I *do* need to have happen -- otherwise my
instantiated objects won't even be functional.

I agree with your assessment that it's at best stylistically poor to skip a
constructor. But at some level I think this highlights a broader issue:
class designers need to be very careful what assumptions they make in the
constructors, because those cannot be overridden in quite the same way as
normal methods. Indeed, it seems constructor code should be limited to *just
what is required to actually construct the object*. If there is other
initialization stuff to be done, it should be done via a separately-defined
method (_init or something like that) which subclasses can override. 

In particular, I think the QooxDoo _createChildControlImpl pattern is 99%
right, but still needs a bit of refinement with respsect to this constructor
issue. These child controls are treated as first-class citizens in some
ways, and second-class citizens in other ways. In this case, for example, I
can inherit from ComboBox and change _createChildControlImpl to alter the
way the children are created, but I can't change the code in the constructor
that forwards events to one of the children. (It seems that the event
forwarding code should be moved into _createChildControlImpl.)

Put another way: designing a truly reusable class hierarchy is *hard*...

Dave


What about using inheritance or adding extra parameter to constructor?
I think that it's wrong approach to skip calling constructors.

-- 
View this message in context: 
http://www.nabble.com/Call-constructor-of-superclass-of-superclass-tp25391812p25400937.html
Sent from the qooxdoo-devel mailing list archive at Nabble.com.


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to