Re: Convention for init with error
Re: Convention for init with error
- Subject: Re: Convention for init with error
- From: "Brad O'Hearne" <email@hidden>
- Date: Wed, 27 Feb 2013 18:43:25 -0700
Quincey and John,
Thank you both for the replies and opinions. I do like the factory method approach, however there is something about a mandatory process or workflow for using an object that seems like it should naturally be put in an init method. It sometimes strikes me a little weird when I think "I just did an init, but the object in reality isn't initialized -- there's still these other steps that must be accomplished. I guess it is a semantic difference, but even one that I've wondered in Apple's API too...factories over here, but no factories over there; init leaves an object in the desired state over here, but over there you need to init and invoke methods 1-2 before the object is in a proper state to be freely used.
Maybe it is just philosophy, but I try to be disciplined and consistent in my coding, so I thought this to be a good learning situation for me to see how others approached it. Thanks for the insight, guys.
Brad
On Feb 27, 2013, at 2:50 PM, Quincey Morris <email@hidden> wrote:
> P.S. I agree with John's statement that a factory method is better (especially with ARC) for your class's public interface, but even within the class implementation you might not be able to avoid the need to return an error from a private 'init'.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden