Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arrayCount should be named something else #59

Open
franklau12 opened this issue Dec 19, 2014 · 4 comments
Open

arrayCount should be named something else #59

franklau12 opened this issue Dec 19, 2014 · 4 comments

Comments

@franklau12
Copy link

Is it possible to change this line:
NSInteger arrayCount = [self.array count];

to either
NSInteger names = self.names.count, or NSInteger names = [self.names count]

This is because I've seen a lot of inexperienced developers use array when naming an array, even though they should name using as high level of abstraction as possible (i.e. instead of nameArray, they should use names). And I think your style guide has a big influence within the Objective-C community.

Thanks

@funkyboy
Copy link
Contributor

Maybe you mean

NSInteger namesCount = ...

?

@gregheo
Copy link
Contributor

gregheo commented Dec 19, 2014

I'd call the array names and the counter nameCount but otherwise that makes sense to me.

The bigger point is count was a method and not a property in the old days, but we should switch to self.names.count. Perhaps we have Swift to thank for turning such things into properties in the modern runtime!

@franklau12
Copy link
Author

Thanks for the quick reply guys, I did mean nameCount or numNames, sorry :(
Yes, Thanks for pointing that out, Greg. self.name.count would be better
since count is a property

@franklau12
Copy link
Author

Could we do it this way. Since count is now a property, it'd be now under the preferred section

Preferred:
NSInteger nameCount = self.names.count;

Not Preferred:
NSInteger nameCount = [self.names count];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants