|
Boost Users : |
From: gast128 (gast128_at_[hidden])
Date: 2007-03-15 07:15:56
> > I agree. At my workplace we have a convention. For heavyweight objects
> > that would do interesting things in their constructors we instead use the
> > alloc-init paradigm of Objective-C. In this model, the constructor does
> > simply non-error things, then a corresponding init (or even suite of init
> > methods) does the interesting things. This has the added benefit that the
> > init method can be overridden in subclasses, and you don't need to
> > re-implement all the behaviors.
>
> The alloc-init paradigm _really_ sucks. Instead of considering
> exceptions in your constructors you end up having to guard all the
> rest of the code with "what if this object failed its initialization?"
> checks/handlers.
>
I wouldn't use that strong words. At least you have the advantage to use
virtual functions which are not behaving like virtuals in constructors as the
orginal poster describes. Buschmann describes in 'posa' the use of MVC in this
way.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net