On Feb 2, 2016, at 11:16, Kevin Schlei via swift-evolution < > swift-evolution@swift.org> wrote:
Sorry for the premature send! Continuing:
let content = listItemView.text.trimming(.whitespaceAndNewlines)
For a beginning programmer, there is no indication of what .trimming does.
In this case, it returns a new string instance. Where is that explained? In
the documentation. Nowhere near the method call.
So are we reduced now to looking up documentation just to read code? What
does this line do:
let next = current.updating(p)
It's 100% unclear because you're relying on parameter names to contain all
the hints. But this line:
I think it's only unclear because p is not a descriptive name (next and
current aren't terribly helpful either), and we don't have any context or
type information.
let next = current.locationByUpdatingProximity(p)
This is definitely more clear when you completely separate these lines
from their context, but code isn't written or read in complete isolation
like this, so I think these examples significantly exaggerate the ambiguity
of the pattern in the real world.
Even if you only make the minor change of renaming p to proximity (which
is really what it should be), the first example becomes pretty clear:
let next = current.updating(proximity)
Ultimately, I don't think this is a very difficult pattern to learn. Maybe
the first handful of times you see it you'll need to read the documentation
to know exactly what it's doing, but once you've seen it a few times, it's
an instantly recognizable pattern. If you see a gerund method, it returns a
new thing by doing the verb to the thing. Is it worth the redundancy and
noise to save new developers from possibly needing to look at a method's
documentation a few times?
I see the tradeoff here as a minor, essentially one-time decrease in
clarity for new developers, and a small but indefinite increase in clarity
for everyone else.
When is the last time you saw a gerund (-ing) as a method name? I wouldn't
let my students write that. Gerunds make good boolean properties. How would
you even read the first line above out loud? Probably by filling in the
words in the second line, magically.
Not having used this pattern before isn't a valid reason to not start
using it, and the API design guidelines already provide a fine pattern for
boolean properties, so we don't need gerunds for them.
My second major issue is that autocomplete grouping is totally lost when
dropping the type returned at the beginning of the call. How many of us
learned a *ton* when we just autocompleted .stringBy? Look at all the
things you can do! But by removing the 'useless word' (really don't like
that flag name) we have no grouping of constructor methods.
I agree that this is kind of unfortunate, but I also don't think that it's
a good idea to limit our API design for the sake of autocomplete discovery.
Documentation is readily available and is a far better form of discovery
since you don't just see things that start with the same prefix that you're
using. The tradeoff is that you have to go out of your way to do it, but
these are the kinds of good habits we should be teaching students.
I see a lot of discussion on how to deal with 'with' and 'by' and other
words, but I want to strongly suggest that the current naming practices
provide context and clarity. It makes code readable and accessible. Don't
forget about when you didn't know how to code! These method names are
teaching tools!
Finally, I just want to ask: why? What is the great benefit? Shouldn't
clarity be prioritized over brevity (where have I seen that...)
I can't put it better than another forums poster:
Does the Swift team seriously believe that systematically parsing and
extensively munging patterns in not-quite-natural-language is tractable to
support all the corner cases for? And that, even if it were, that it could
avoid confusion in less-than-perfect codebases? The idea that this will
somehow benefit a language, particularly one in which clear and obvious
bridging is so vital is *insane*. The best it can do is a reasonable
job, with some amount of either unfixable brokenness forced upon developers
in perpetuity, or constant churn stemming from perpetual fixing of
brokenness. Swift's translation is currently simple to reason about, and
the language as a whole has got a really great thing going on. I'm really
happy with where it is at this moment. Why ruin it by boneheadedly
detonating the utility of two years of progress in literature and the
library of online information about Swift? Seriously, why?
On Tue, Feb 2, 2016 at 1:04 PM, Kevin Schlei <kevinschlei@gmail.com> > wrote:
I am strongly against the proposed changes to the translation of
Objective-C APIs. I think the changes promote terseness for terseness sake,
lose vital context in method names, and are a huge loss pedagogically.
If you teach programming, you'll know why this line will be a nightmare:
let content = listItemView.text.trimming(.whitespaceAndNewlines)
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution