Re: Obj-C - your thoughts on hiding data members?
Re: Obj-C - your thoughts on hiding data members?
- Subject: Re: Obj-C - your thoughts on hiding data members?
- From: Alex Zavatone <email@hidden>
- Date: Tue, 26 Jan 2016 09:32:08 -0500
On Jan 26, 2016, at 5:47 AM, Dave wrote:
> Hi,
>
>> Yeah, the ivar for an @property called myThing is _myThing and we can know that by looking at it with our eyeballs. How do we extend that type of visual exposure of information of the “thing” being inspected in a similar manner?
>>
>> Do we have any standards for this?
>>
>> If not, should we create some?
>
> There are no standards AFAIK and you will never get everybody to agree a “standard” naming convention, I have my own scheme though:
>
> Entry Parameters to Methods are prefixed the “the”, local Variables are prefixed “my”, properties are prefixed “p”, Ivar’s “m”, constants “k” and I always try to give some clue as to the type of the data in the variables, e.g. myNameDict, myAddresssAddress, etc.
>
> Cheers
> Dave
I'm a big fan of using my in front of local variables as well.
Since we're all computery and programmy and stuff, couldn't we put together a little matrix of the type of variable and come up with several loose standards?
The reason I ask this (am pressing on this) is that a large amount of what communicates to the programmer is in the naming and casing convention of the words used.
All too recently, I have had to deal with code where the programmers used completely arbitrary conventions to casing absolutely everything. Methods, classes, properties, ivars, methods, functions, all of them were arbitrarily named and cased, making converting the code into something manageable a multi month lesson in pain.
One very nice thing about Objective-C/Cocoa is that we have naming conventions that communicate to the user what we are looking at.
As we now have the opportunity to take advantage of these techniques that Greg, Graham, Quincy, Snej, et al. are bringing to our attention, it's the perfect time to at least try out some conventions that clearly tell the programmer what the thing is simply by looking at it.
I think it's a prime opportunity to at least start this.
Just my 2 cents on the matter adjusted for inflation.
Alex Zavatone
> _______________________________________________
>
> 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
_______________________________________________
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