On Apr 30, 2009, at 12:53 AM, Kyle Sluder wrote:

On Thu, Apr 30, 2009 at 1:44 AM, Jeff Johnson
<publicpost...@lapcatsoftware.com> wrote:
On an unrelated note, your use of "self->connection", etc., is non- standard
and not advised. You should be using direct ivar access "connection",
properties "self.connection", or accessor methods "[self connection]".

Sure, `self->connection` is redundant with just plain old
`connection`, but they amount to the same thing.  Unless there's some
new-runtime trickery going on that I'm not aware of.

--Kyle Sluder

It amounts to the same thing, but it's a bad habit to get into. It's redundant, as you say, for an object's own instance variables. And you shouldn't be trying to directly access the instance variables of other objects. According to the documentation, "Marking instance variables @public defeats the ability of an object to hide its data. It runs counter to a fundamental principle of object-oriented programming—the encapsulation of data within objects where it’s protected from view and inadvertent error. Public instance variables should therefore be avoided except in extraordinary cases." Thus, except in extraordinary cases, there's no reason to use the "object->ivar" syntax.

-Jeff

_______________________________________________

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