Re: semantics of init
Re: semantics of init
- Subject: Re: semantics of init
- From: "Cameron S. Bahan" <email@hidden>
- Date: Wed, 4 Jun 2003 14:40:21 -0400
I prefer to use accessor methods whenever I need to access or query a
variable, including constructors and destructors ( -init and -dealloc
). To me this assists in maintaining the code base (even with private
variables). If any changes are made in setting / retrieving the
variable, changes to the variable name, or changes to the variable
definition - the single point of access of the get/set routines makes
the change go a lot smoother. If, however, that is not followed in all
cases ( thus including -init ) then you increase the possibilities for
introducing bugs into the code.
If, however, you are constrained by performance and your optimization
traces back to using the accessors in your constructors and destructors
... then Obj-C is not likely the technical solution you are looking
for. Moving to C++ or even further into C might be a choice you should
consider.
Thoughts ? comments ?
On Wednesday, June 4, 2003, at 01:42 PM, Marcel Weiher wrote:
>
On Wednesday, June 4, 2003, at 04:32 Uhr, Daniel Zitter wrote:
>
>
>>
>
>> 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.
>
>
You've got a well-developed olfactory organ there ;-)
>
>
Regards,
>
>
Marcel
>
>
--
>
Marcel Weiher Metaobject Software Technologies
>
email@hidden www.metaobject.com
>
Metaprogramming for the Graphic Arts. HOM, IDEAs, MetaAd etc.
>
f0249ab8b1af193ef5addcf39fdff5ca
>
_______________________________________________
>
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.
>
--
Cameron Bahan
Computer Systems Analyst, METI
http://www.meti.com
_______________________________________________
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.