[OGo-Developer] WODirectAction not initted? (fwd)

Helge Hess developer@opengroupware.org
Fri, 8 Jun 2007 17:00:48 +0200


On Jun 8, 2007, at 16:44, Wolfgang Sourdeau wrote:
> Actually I have found the problem
>
> In WODirectAction, init calls [self initWithRequest: nil], which in  
> turn calls [super init]. This explains why my method was never called.
>
> I think this is bad practice because any Objective-C object is  
> expected to possibly have an init method to instantiate its  
> attributes... In which case, the call chain should be the other way  
> around.... initWithRequest should call [self init] which then  
> should call [super init].

Uhm, no. Objective-C convention is to have a so called 'designated  
initializers' (DI). In SOPE I sometimes tag them explicitly with a  
comment
   // designated initializer
after or before the method name.

For WODirectAction the designated initializer is -initWithRequest:,  
for NSObject -init, and the -init chain looks proper to me.
One could support multiple DIs, but this means more work for  
subclassers since they usually need to override all of them.

> And since init does nothing, it can actually be removed.
>
> Should I submit a patch for this?

I can't really follow the issue. If you want to override an  
initializer in the subclass you need to override the designated  
initializer(s). For WODirectAction subclasses this is -initWithRequest:.

The current code looks fine to me (maybe we should explicitly tag the  
DI). But maybe I'm missing something.

Greets,
   Helge
-- 
Helge Hess
http://www.helgehess.eu/