-
Notifications
You must be signed in to change notification settings - Fork 9
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
Unnamed method parameters should be replaced #1
Comments
Hi Tony, thanks for the feedback! The issue you raise is one I've been struggling for some time and going back and forth as well. There were two issues I had with just plain -translate:
[context moveto:NSMakePoint(0,0)]; The NSMakePoint()s really start to drown out what you're trying to do, similar to the CGContext... prefix when using CG functions.
I also considered other alternatives, such as naming the parameters, but that also got awkward: -translateX:10 y:20. Just looks ugly, if you ask me. Coming from a Postscript background, I never found 0 0 moveto 100 0 lineto 50 50 lineto closepath confusing in terms of what is x and y, so I finally decided to just leave the parameters unnamed, especially since that is used consistently throughout the API. If you see something:100 : 100, you can be sure that this will be a coordinate pair. So yes, the point you raise is a cognizant one, and I am aware that the solution I arrived at is debatable. I just haven't found a better one, yet. |
All fair points, @mpw. Given that most of this really is stylistic, I guess it doesn't matter too much so thankyou for taking the time to explain your thinking. |
actually -translateByX:10 andY:10 is not ugly. It is self explaining, and closer to human language. Even if a little longer to write, (that's ObjC...) I would always prefer reading such code. -translate:10:20 forces me to either jump to the headers time and again to see what are the first and second params, or to memorize the signatures of too many API calls. |
This looks like a great project, Marcel — I noticed in some of the samples you've posted to the mailing list and elsewhere that some of the methods use unnamed parameters. ie.
This is not great practice, and I feel you'd be better off using something simpler like:
I don't think a change like this violates what you're trying to achieve here, but it also means that you're not off the beaten path of unreadable method names.
The text was updated successfully, but these errors were encountered: