<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);"> let foreground = Color(havingRGBValuesRed: 32, green: 64, andBlue: 128) <br class=""></span></div><div class=""><span style="background-color: rgba(255, 255, 255, 0);">"Having" and "and" are unnecessary... Should be </span></div><div class=""><span style="background-color: rgba(255, 255, 255, 0);"> let foreground = Color(red: 32, green: 64, blue: 128) </span></div><div class=""><br></div><div class=""><span style="background-color: rgba(255, 255, 255, 0);"> let newPart = factory.makeWidget(havingGearCount: 42, andSpindleCount: 14) <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);"> let newPart = factory.makeWidget(gearCount: 42, spindleCount: 14) </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);"> let newPart = factory.makeWidget(gears: 42, spindles: 14) </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);"> 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);"> let ref = Link(url: destination)</span></div>Or...</div><div><span style="background-color: rgba(255, 255, 255, 0);"> 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);">* <a href="https://leanpub.com/wepntk">https://leanpub.com/wepntk</a> <- buy my book?<br>* </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>* <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 <<a href="mailto:swift-users@swift.org">swift-users@swift.org</a>> 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"><<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>></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> says :<div><br></div><div>> 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>> let foreground = Color(havingRGBValuesRed: 32, green: 64, andBlue: 128) <br></div><div>> let newPart = factory.makeWidget(<wbr>havingGearCount: 42, andSpindleCount: 14) <br></div><div>> let ref = Link(to: destination) </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> struct Array<T> {</div><div> // ...<br> init(repeating repeatedValue: Array.Element, count: Int)<br> }</div><div><br></div><div> struct Data {</div><div> // ...</div><div> init(referencing reference: NSData)</div><div> }</div><div><br> class UIImage {</div><div> // …</div><div> init?(named name: String, in bundle: Bundle?, <wbr>compatibleWith traitCollection: <wbr>UITraitCollection?)<br> }</div><div><br></div><div>I understand that some UIKit methods inherit their ObjC declarations like <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>