[swift-evolution] [Guidelines, First Argument Labels]: Prepositions inside the parens

Radosław Pietruszewski radexpl at gmail.com
Thu Feb 11 16:33:24 CST 2016


> On 11 Feb 2016, at 23:18, Charles Kissinger <crk at akkyra.com> wrote:
> 
> 
>> On Feb 11, 2016, at 1:51 PM, Brent Royal-Gordon <brent at architechies.com> wrote:
>> 
>>>> Between these two (sorry to repeat the same example again):
>>>> 
>>>> func trackWith(trackID trackID: CMPersistentTrackID) -> AVAssetTrack?
>>>> func track(withTrackID trackID: CMPersistentTrackID) -> AVAssetTrack?
>>> 
>>> I think this one particular function is possibly the worst case in the entire API. Neither “track” nor “trackWith” is a particularly good function name. But as I mentioned in a previous post, I think, for many of the Foundation functions, moving the prepositional phrase into the argument label actual aids clarity slightly. I was surprised that I ended up liking it, but I do.
>> 
>> Looking at the fourth function in the diff and saying "I think this is probably the worst API in the frameworks" is a bit like looking at Jupiter and saying "I think this is probably the biggest planet in the universe". With such a small sample out of such a large set, it's far more likely that APIs with the defects seen here are *common*.
> 
> I did in fact scan through large portions of the the Foundation universe before coming to that conclusion. :-) One problem with both “track” and “trackWith” is that track can be either a noun or a verb in either case. We’ve been using this function as an exemplar right from the start, but it probably isn’t a great one.
> 
> Those who feel there are a lot of problematic function names after the latest guideline changes should certainly collate a list.
> 
> —CK


Ha, true, being both a noun and a verb doesn’t help. Still, it’s not that uncommon — this might be a particularly tricky API, and I tend to agree — but mostly it’s an issue of how initializer/getter-like are named. There’s _a lot_ of method names that are just nouns — which is a large part of the “prepositions being useful” problem.

— Radek



More information about the swift-evolution mailing list