<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto">I think the advice is really to avoid unnecessary "helper" words in the names<div><br></div><div><div class=""><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; let foreground = Color(havingRGBValuesRed:&nbsp;32, green:&nbsp;64, andBlue:&nbsp;128) &nbsp;<br class=""></span></div><div class=""><span style="background-color: rgba(255, 255, 255, 0);">"Having" and "and" are unnecessary... Should be &nbsp;</span></div><div class=""><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; let foreground = Color(red:&nbsp;32, green:&nbsp;64, blue:&nbsp;128)&nbsp;</span></div><div class=""><br></div><div class=""><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; let newPart = factory.makeWidget(havingGearCount:&nbsp;42, andSpindleCount:&nbsp;14) &nbsp;<br class=""></span></div><div class=""><span style="background-color: rgba(255, 255, 255, 0);">Again, "having" and "and" are not needed... Should be</span></div><div class=""><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; let newPart = factory.makeWidget(gearCount:&nbsp;42, spindleCount:&nbsp;14)&nbsp;</span></div><div class=""><span style="background-color: rgba(255, 255, 255, 0);">Or...</span></div><div class=""><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; let newPart = factory.makeWidget(gears:&nbsp;42, spindles:&nbsp;14)&nbsp;</span></div><div class=""><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div><div class=""><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; let ref = Link(to: destination)</span></div><div class=""><span style="background-color: rgba(255, 255, 255, 0);">In this case, "to" is kinda useful. Though it might be better if the label names the thing.</span></div><div class=""><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp;&nbsp;let ref = Link(url: destination)</span></div>Or...</div><div><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; let ref = Link(target: destination)</span></div><div><br><div id="AppleMailSignature"><span style="background-color: rgba(255, 255, 255, 0);">--<br>C. Keith Ray</span><div><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div><div><span style="background-color: rgba(255, 255, 255, 0);">*&nbsp;<a href="https://leanpub.com/wepntk">https://leanpub.com/wepntk</a>&nbsp;&lt;- buy my book?<br>*&nbsp;</span><a href="http://www.thirdfoundationsw.com/keith_ray_resume_2014_long.pdf">http://www.thirdfoundationsw.com/keith_ray_resume_2014_long.pdf</a><span style="background-color: rgba(255, 255, 255, 0);"><br>*&nbsp;<a href="http://agilesolutionspace.blogspot.com/">http://agilesolutionspace.blogspot.com/</a></span></div></div><div><br>On Jan 9, 2018, at 12:10 PM, Kelvin Ma via swift-users &lt;<a href="mailto:swift-users@swift.org">swift-users@swift.org</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr">I didn’t write the guidelines but i never really felt Array(repeating:count:) was weird, you have two arguments, they need to be distinguished, and repeating is actually shorter than repeatedValue.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 9, 2018 at 12:09 PM, Gaétan Zanella via swift-users <span dir="ltr">&lt;<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><a href="https://swift.org/documentation/api-design-guidelines" target="_blank">Swift API Design Guide</a>&nbsp;says :<div><br></div><div>&gt; &nbsp; &nbsp;The first argument to initializer and factory methods calls should not form a phrase starting with the base name</div><div><br></div><div>Specially, it advises us against writing things like :</div><div><br></div><div><div>&gt; &nbsp; &nbsp;let foreground = Color(havingRGBValuesRed:&nbsp;32, green:&nbsp;64, andBlue:&nbsp;128) &nbsp;<br></div><div>&gt; &nbsp; &nbsp;let newPart = factory.makeWidget(<wbr>havingGearCount:&nbsp;42, andSpindleCount:&nbsp;14) &nbsp;<br></div><div>&gt; &nbsp; &nbsp;let ref = Link(to: destination) &nbsp;</div></div><div><br></div><div>But in UIKit, the Swift Standard Library or in Foundation, we find code like :</div><div><br></div><div><div>&nbsp; &nbsp;&nbsp;struct&nbsp;Array&lt;T&gt; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; // ...<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;init(repeating repeatedValue:&nbsp;Array.Element, count:&nbsp;Int)<br>&nbsp; &nbsp;&nbsp;}</div><div><br></div><div>&nbsp; &nbsp; struct Data {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; // ...</div><div>&nbsp; &nbsp; &nbsp; &nbsp; init(referencing reference: NSData)</div><div>&nbsp; &nbsp; }</div><div><br>&nbsp; &nbsp;&nbsp;class&nbsp;UIImage {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; // …</div><div>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;init?(named name:&nbsp;String,&nbsp;in bundle:&nbsp;Bundle?,&nbsp;<wbr>compatibleWith traitCollection:&nbsp;<wbr>UITraitCollection?)<br>&nbsp; &nbsp;&nbsp;}</div><div><br></div><div>I understand that some UIKit methods inherit their ObjC declarations like&nbsp;<a href="https://developer.apple.com/documentation/uikit/uiimage/1624154-imagenamed?language=objc" target="_blank">imageNamed:inBundle:<wbr>compatibleWithTraitCollection:</a><wbr>.</div><div>But what about Foundation and the Swift Standard Library ?</div></div><div><br></div><div>I agree that the initializers respect the Swift fundamentals : clean, short, readable, and consistent.</div><div>But the guide seems to be clear about it : we should not write such things.</div><div><br></div><div>Could someone shed some light on this point for me ? The subtlety about it.</div></div><br>______________________________<wbr>_________________<br>
swift-users mailing list<br>
<a href="mailto:swift-users@swift.org">swift-users@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-users</a><br>
<br></blockquote></div><br></div>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-users mailing list</span><br><span><a href="mailto:swift-users@swift.org">swift-users@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-users">https://lists.swift.org/mailman/listinfo/swift-users</a></span><br></div></blockquote></div></body></html>