Re: subclass overwriting superclass ivar
Re: subclass overwriting superclass ivar
- Subject: Re: subclass overwriting superclass ivar
- From: Graham Cox <email@hidden>
- Date: Wed, 26 May 2010 23:29:11 +1000
On 26/05/2010, at 11:10 PM, vincent habchi wrote:
> So, tell me if I'm wrong, but I infer from your answer that whatever I can do, there is no means for a subclass A' to access any private variable of its ancestor.
Correct, if class A has not declared an accessor to it, and you haven't added one via a category (thanks Roland).
> Well, as a regular Python code writer, I've never missed @private (or even @protected) declarations. I fail anyhow to grasp the relevancy of @private vis-à-vis @protected: It seems logical to me that subclasses be granted access to all ancestor attributes.
For yourself it might not be all that useful, after all you know how your own code works (well, sometimes ;-) and are not tempted to abuse it without thought. For code that you release to a wider audience, it is useful in that it eliminates an easy form of abuse that you likely didn't consider in your design. Anything you can do to encourage (or force) a user of your code NOT to take the wrong path is a useful tool to employ. Just decalring certain ivars @private sends the message to the next developer: "don't touch these".
--Graham
_______________________________________________
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