[swift-evolution] [Review] SE-0005 Better Translation of Objective-C APIs Into Swift
Douglas Gregor
dgregor at apple.com
Wed Jan 27 17:01:12 CST 2016
> On Jan 27, 2016, at 11:22 AM, Ben Rimmington <me at benrimmington.com> wrote:
>
> Doug,
>
>> On 27 Jan 2016, at 07:50, Douglas Gregor via swift-evolution <swift-evolution at swift.org> wrote:
>>
>> Another random interesting example I encountered:
>>
>> - func addArcWithCenter(center: CGPoint, radius: CGFloat, startAngle: CGFloat, endAngle: CGFloat, clockwise: Bool)
>> + func addArc(center center: CGPoint, radius: CGFloat, startAngle: CGFloat, endAngle: CGFloat, clockwise: Bool)
>>
>> which seems to match the idea behind Erica’s "semantic relationship between the parameters is stronger than their relation to the operation” (or Paul Cantrell’s similar notion of "the direct object is several args taken together”, which feels more in line with the way the API guidelines are written).
>
> The related AppKit.NSBezierPath method contains two possible "With" separators:
>
>> - (void)appendBezierPathWithArcWithCenter:(NSPoint)center
>> radius:(CGFloat)radius
>> startAngle:(CGFloat)startAngle
>> endAngle:(CGFloat)endAngle
>> clockwise:(BOOL)clockwise
>
> Your patch replaces the second "With" separator, but the alternative might be better:
>
>> // YOUR PATCH:
>> func appendWithArc(center center: Point, radius: CGFloat, startAngle: CGFloat, endAngle: CGFloat, clockwise: Bool)
>>
>> // THE ALTERNATIVE:
>> func append(arcWithCenter center: Point, radius: CGFloat, startAngle: CGFloat, endAngle: CGFloat, clockwise: Bool)
Applying this heuristic changes the two “appendWithArcWithCenter” methods along, and one other place in the SDK:
- func isUnifiedWithContact(identifier contactIdentifier: String) -> Bool
+ func isUnified(contactWithIdentifier contactIdentifier: String) -> Bool
this one seems worse.
- Doug
More information about the swift-evolution
mailing list