Re: semantics of init
Re: semantics of init
- Subject: Re: semantics of init
- From: Daniel Zitter <email@hidden>
- Date: Wed, 4 Jun 2003 07:32:22 -0700
Date: Wed, 4 Jun 2003 23:16:56 +1000
Subject: Re: semantics of init
Cc: Marcel Weiher <email@hidden>, email@hidden
To: j o a r <email@hidden>
From: Wade Tregaskis <email@hidden>
So I use my accessors to avoid direct instance variable access. This
protects me from self being nil without the test, and it even
protects me from a different type of object being returned. (If the
object being returned isn't compatible in the message-interface, then
it is just broken).
The problem that I see with using accessor methods in init is that it
could possibly create maintenance problems. Sending messages to "self"
before "self" is fully initialized could possibly create situations
where you, if you're not carefyl, try to access parts of "self" that
is not yet initialized. Do you see this as a problem, and if so, how
do you deal with that?
Another problem I'm seeing with this approach is performance - I don't
think ObjC messages can be inlined, by definition, so every [self xxx]
call is an extra expense you could probably do without. Plus, it may
muck up your object's initial message cache, by using a bunch of setter
methods that don't otherwise get used. So you'd see an extra
performance loss, initially.
I don't buy the argument that the use of setter methods in -init would
substantially degrade performance.
This smells like premature optimization to me.
Cheers,
Dan
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.