FROM : Scott Stevenson
DATE : Wed Nov 24 21:32:12 2004
On Nov 24, 2004, at 11:58 AM, Ricky Sharp wrote:
> e.g.: float mShadowOffset;
> e.g.: int foo (int inAddend, int inAugend, int& outSum)
>
> (3) Because of the prefix rules above, all local variables would not
> have any prefix. Thus, locals var names never collided with ivars or
> parameters.
[...]
> Is anyone else doing something similar? Is this to be frowned upon?
> I have no problem in changing my practices to adhere to the
> guidelines.
I rarely see it in Code, and Apple's guidelines don't mention it at
all. I think the main problem with something like this from Cocoa's
persepective is that something like "m" is pretty terse.
I think I read a recommendation in Apple's docs somewhere that local
vars can have the prefix "my" if the name is otherwise the same as an
ivar. You can also "the". The point is to make it readable, and "m"
isn't ideal for that. Same with "pz" and such.
> Also, for foo, should I really be calling the accessor everywhere
> rather than having a local?
>
> - (void)foo
> {
> [self someMethod:[self someAttribute]];
> [self anotherMethod:[self someAttribute]];
> }
I personally think this is wasteful, but it really depends on how how
often -foo is called and the context. Sometimes someAttribute won't be
the same from one line to the next.
- Scott
--
http://treehouseideas.com/
http://theobroma.treehouseideas.com/ [blog]
DATE : Wed Nov 24 21:32:12 2004
On Nov 24, 2004, at 11:58 AM, Ricky Sharp wrote:
> e.g.: float mShadowOffset;
> e.g.: int foo (int inAddend, int inAugend, int& outSum)
>
> (3) Because of the prefix rules above, all local variables would not
> have any prefix. Thus, locals var names never collided with ivars or
> parameters.
[...]
> Is anyone else doing something similar? Is this to be frowned upon?
> I have no problem in changing my practices to adhere to the
> guidelines.
I rarely see it in Code, and Apple's guidelines don't mention it at
all. I think the main problem with something like this from Cocoa's
persepective is that something like "m" is pretty terse.
I think I read a recommendation in Apple's docs somewhere that local
vars can have the prefix "my" if the name is otherwise the same as an
ivar. You can also "the". The point is to make it readable, and "m"
isn't ideal for that. Same with "pz" and such.
> Also, for foo, should I really be calling the accessor everywhere
> rather than having a local?
>
> - (void)foo
> {
> [self someMethod:[self someAttribute]];
> [self anotherMethod:[self someAttribute]];
> }
I personally think this is wasteful, but it really depends on how how
often -foo is called and the context. Sometimes someAttribute won't be
the same from one line to the next.
- Scott
--
http://treehouseideas.com/
http://theobroma.treehouseideas.com/ [blog]
| Related mails | Author | Date |
|---|---|---|
| Sanoop | Nov 24, 07:17 | |
| Wade Tregaskis | Nov 24, 07:25 | |
| j o a r | Nov 24, 07:32 | |
| Sanoop | Nov 24, 09:37 | |
| Shawn Erickson | Nov 24, 18:03 | |
| Ricky Sharp | Nov 24, 20:58 | |
| Scott Stevenson | Nov 24, 21:32 | |
| Sherm Pendley | Nov 24, 22:27 | |
| Ricky Sharp | Nov 24, 22:41 | |
| M. Uli Kusterer | Nov 25, 21:47 | |
| Andrew Farmer | Nov 26, 23:00 |






Cocoa mail archive

