On Apr 8, 2010, at 10:21 AM, Patrick M. Rutkowski wrote:

> Agreed, but there's always the danger the +array method, which might
> actually be implemented in NSArray.m, will not properly initialize the
> more specific NSMutableArray object.
> 
> Of course, in this specific case that's the case, but it might be the
> case with other class hierarchies.
> 
> But, nonetheless I'm troubled that nobody in this thread has
> acknowledged that yet :-o

Because, in practice, that doesn't generally happen. 

Across the system supplied frameworks, classes generally have designated 
initializers and those initializers are inherited properly.  The convenience 
creation methods -- factory methods, if you will -- are dead simple stupid, 
generally doing the equivalent of '[[[self alloc] init*] autorelease]' where 
the init part calls the designated initializer.

If a subclass needs a more specific initializer, the inherited, simpler, 
initializer from the superclass is typically overridden to barf an error or 
call the more specific with a default argument.

Thus, the risk is largely -- there are probably an exception or two and, if you 
know of one, file a bug -- confined to the code you write.   Generally, class 
hierarchies in Objective-C tend to be relatively shallow and relatively well 
factored (if you are doing it right, anyway).    When there is inheritance, the 
most effective use is in maintaining consistency in interface across super and 
subclasses, including the designated initializers.

So, again, in your own code the risk should be relatively minor in a clean 
design.

Now, of course, none of us are perfect and just about all of us have put 
together a shoddily architected, way too deep, class hierarchy now and again.   
Even when slinging crap code, there is no reason why it can't be defensive crap 
code, too!

b.bum

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to