<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 22, 2016, at 4:26 PM, Michael Wells via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="gmail_extra"><div class="gmail_quote">On Sat, Jan 23, 2016 at 12:00 AM, David Owens II via swift-evolution <span dir="ltr" class="">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><blockquote type="cite" class=""><div class=""><div class=""><b class="">Compensate For Weak Type Information&nbsp;as needed to clarify a parameter’s&nbsp;role.<br class=""></b></div><div class=""><br class=""></div>Especially when a parameter type is&nbsp;NSObject,&nbsp;Any,&nbsp;AnyObject, or a fundamental type such&nbsp;Int&nbsp;or&nbsp;String, type information and context at the&nbsp;point of use may not fully convey intent. In this example, the declaration may be clear, but the use site is vague:<br class=""><br class=""></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px" class=""><div class=""><div class=""><font face="Menlo" class="">func add(observer: NSObject, for keyPath: String)</font></div></div><div class=""><div class=""><font face="Menlo" class="">grid.add(self, for: graphics) // vague</font></div></div></blockquote><div class=""><br class="">To restore clarity,&nbsp;precede each weakly-typed parameter with a noun describing its role:<br class=""><br class=""></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px" class=""><div class=""><font face="Menlo" class="">func addObserver(_ observer: NSObject, forKeyPath path: String)</font></div><div class=""><div class=""><font face="Menlo" class="">grid.addObserver(self, forKeyPath: graphics) // clear</font></div></div></blockquote></blockquote><div class=""><br class=""></div></div></blockquote></div></div></blockquote><br class="">Where this rule feels clumsy to me is in code such as<br class=""><br class=""><font face="Menlo" class="">func loginWithUsername(username: String, password: String) -&gt; Bool</font><br class=""><br class="">vs.<br class=""><br class=""><font face="Menlo" class="">func login(username: String, password: String) -&gt; Bool<br class=""></font><br class="">But maybe it just takes some time to get used to the style.</div></div></div></blockquote><div><br class=""></div><div><br class=""></div></div>I much prefer the second version:<div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><font face="Menlo" class="">func login(username name: String, password: String) -&gt; Bool</font></div><div class=""><font face="Menlo" class="">login(username: “bob”, password: “1234”)</font></div><div class=""><font face="Menlo" class=""><span style="font-family: Helvetica;" class=""><br class=""></span></font></div></div></div></blockquote><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><font class="">-David</font></div></div></body></html>