[swift-evolution] [Discussion] API Guidelines

William Sumner prestonsumner at me.com
Fri Oct 14 10:38:20 CDT 2016


> On Oct 14, 2016, at 8:49 AM, Adrian Zubarev via swift-evolution <swift-evolution at swift.org> wrote:
> 
> I’m still not convinced in some cases.
> 
> Take a look at UIViews and its method addSubview.
> 
> open func addSubview(_ view: UIView)
> Personally I’d change or write this function like so:
> 
> open func add(subview: UIView)
> This reduces unnecessary noise _ view for both the implementation and usage.
> 
> // Implementation
> open func add(subview: UIView) {
>     // `subview` is descriptive and just fine here
> }
> 
> // Usage
> 
> self.view.add(subview: someOtherView)
> 
> 
> 
> -- 
> Adrian Zubarev
> Sent with Airmail

This conforms to the following rule from the Argument Labels section of the naming guidelines:

“[I]f the first argument forms part of a grammatical phrase, omit its label, appending any preceding words to the base name, e.g. x.addSubview(y)"

Preston
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20161014/e8b53547/attachment.html>


More information about the swift-evolution mailing list