Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

One thing that irks me is that the author doesn't stick to ObjC naming conventions.

Take for example the capitalize methods. In ruby, you have "capitalize" and "capitalize!" to distinguish the immutable and mutable versions. To make this distinction in ObjC, you generally use nouns vs. verbs. So for the equivalent of ruby's "capitalize", you'd use "capitalizedString" (which is in fact provided by NSString). But the mutable version, the equivalent of ruby's "capitalize" should simply be "capitalize", not "capitalizedStringInPlace".



-(NSString*)capitalizeInPlace; is the actual signature.

The reasoning for this is for consistency, while still maintaining autocomplete proximity.


I'm not really sure I understand; why would calling the method "capitalize" instead of "capitalizeInPlace" be inconsistent?

(Also, the comments in the header file and the README file contain the name "capitalizedStringInPlace" instead of "capitalizeInPlace")

Another inconsistency is that most mutating methods in ObjectiveC don't return self, but either void or a boolean or an integer that reports if the method succeeded. But I assume that this inconsistency is on purpose because you want to make the methods chainable.


The issue with the default syntax in NSString is that the mutating methods are the more concise, but are also the ones you use the least. It makes far more sense for the more used methods to be more concise than their mutating siblings.

I don't disagree with you though. I'd prefer if the interface for this was more idiomatic.

Returning void is sort of pointless. A boolean, maybe. I feel like returning self is just making better use of things, really, and probably doesn't really cause any confusion.


Okay, now I get it, the naming makes autocomplete more convenient.

Returning void makes it easier to spot errors. If you accidentally use "capitalizeInPlace" instead of "capitalizedString" your code will compile without issues. If the mutating method returned void, it would result in a compile error.


That's an extreme edge case though, since if you're using a mutating method, you're using a mutating string, and you're probably aware of that.


What's stopping you from submitting a pull request with these suggestions?


Two reasons:

a) The author might disagree with my asessment. A pull request would imply that I consider it an error, but I think it's more a question of style.

b) I already waste too much time on HN. Forking a project, trying to understand all of it, making changes, writing a pull request, etc. would probably take me all day but I need to clean the kitchen and take care of the kids and work on some overdue client work that I have been postponing for far too long.


If you open a new issue on GitHub, somebody else could fix it.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: