<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="">I like to separate methods into their own logical extensions so similar methods are grouped together. I do this mostly with Cocoa Touch where I like all view life cycle methods to be in the same extension:<div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo; color: rgb(79, 129, 135);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">extension</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">ViewController</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> {</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">override</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span><span style="font-variant-ligatures: no-common-ligatures" class=""> viewDidLoad() {</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> }</span></div><p style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo; min-height: 14px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">override</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span><span style="font-variant-ligatures: no-common-ligatures" class=""> viewWillAppear(animated: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Bool</span><span style="font-variant-ligatures: no-common-ligatures" class="">) {</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> }</span></div><p style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo; min-height: 14px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">override</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span><span style="font-variant-ligatures: no-common-ligatures" class=""> viewDidDisappear(animated: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Bool</span><span style="font-variant-ligatures: no-common-ligatures" class="">) {</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> }</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" class="">You can document this somewhat by adding a MARK comment:</div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class=""><div style="font-family: Menlo; font-size: 12px; margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">// MARK: Lifecylce</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><div style="font-family: Menlo; font-size: 12px; margin: 0px; line-height: normal; color: rgb(79, 129, 135);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">extension</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);" class=""> </span><span style="font-variant-ligatures: no-common-ligatures;" class="">ViewController</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);" class=""> {</span></div><div style="font-family: Menlo; font-size: 12px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">override</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">func</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> viewDidLoad() {</span></div><div style="font-family: Menlo; font-size: 12px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> }</span></div><div style="font-family: Menlo; font-size: 12px; margin: 0px; line-height: normal; min-height: 14px;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><br class="webkit-block-placeholder"></div><div style="font-family: Menlo; font-size: 12px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">override</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">func</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> viewWillAppear(animated: </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);" class="">Bool</span><span style="font-variant-ligatures: no-common-ligatures;" class="">) {</span></div><div style="font-family: Menlo; font-size: 12px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> }</span></div><div style="font-family: Menlo; font-size: 12px; margin: 0px; line-height: normal; min-height: 14px;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><br class="webkit-block-placeholder"></div><div style="font-family: Menlo; font-size: 12px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">override</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">func</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> viewDidDisappear(animated: </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);" class="">Bool</span><span style="font-variant-ligatures: no-common-ligatures;" class="">) {</span></div><div style="font-family: Menlo; font-size: 12px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> }</span></div><div style="font-family: Menlo; font-size: 12px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">}</span></div><div style="font-family: Menlo; font-size: 12px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><br class=""></span></div><div style="font-family: Menlo; font-size: 12px; margin: 0px; line-height: normal;" class="">What if we made this more self-documenting by elevating this to a language feature?</div><div style="font-family: Menlo; font-size: 12px; margin: 0px; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class=""><div style="font-family: Menlo; font-size: 12px; margin: 0px; line-height: normal;" class=""><span style="color: rgb(187, 44, 162); font-variant-ligatures: no-common-ligatures;" class="">extension</span><span style="color: rgb(0, 0, 0); font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures;" class=""><font color="#4f8187" class="">ViewController </font><font color="#bb2ca2" class="">named </font><font color="#d12f1b" class="">Lifecycle</font></span> {</div><div style="font-family: Menlo; font-size: 12px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">override</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">func</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> viewDidLoad() {</span></div><div style="font-family: Menlo; font-size: 12px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> }</span></div><div style="font-family: Menlo; font-size: 12px; margin: 0px; line-height: normal; min-height: 14px;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><br class="webkit-block-placeholder"></div><div style="font-family: Menlo; font-size: 12px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">override</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">func</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> viewWillAppear(animated: </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);" class="">Bool</span><span style="font-variant-ligatures: no-common-ligatures;" class="">) {</span></div><div style="font-family: Menlo; font-size: 12px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> }</span></div><div style="font-family: Menlo; font-size: 12px; margin: 0px; line-height: normal; min-height: 14px;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><br class="webkit-block-placeholder"></div><div style="font-family: Menlo; font-size: 12px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">override</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">func</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> viewDidDisappear(animated: </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);" class="">Bool</span><span style="font-variant-ligatures: no-common-ligatures;" class="">) {</span></div><div style="font-family: Menlo; font-size: 12px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> }</span></div><div style="font-family: Menlo; font-size: 12px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">}</span></div><div style="font-family: Menlo; font-size: 12px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><br class=""></span></div><div style="font-family: Menlo; font-size: 12px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">Other ways:</span></div><div style="font-family: Menlo; font-size: 12px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><span style="color: rgb(187, 44, 162); font-variant-ligatures: no-common-ligatures;" class="">extension </span></span><font color="#bb2ca2" class="">named </font><font color="#d12f1b" class="">Lifecycle</font><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures;" class=""><font color="#4f8187" class="">ViewController { }</font></span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><span style="font-family: Menlo; font-size: 12px; font-variant-ligatures: no-common-ligatures;" class=""><span style="color: rgb(187, 44, 162); font-variant-ligatures: no-common-ligatures;" class="">extension </span></span><font color="#bb2ca2" style="font-family: Menlo; font-size: 12px;" class="">named </font><font color="#d12f1b" class=""><font face="Menlo" class=""><span style="font-size: 12px;" class="">“View Lifecycle"</span></font></font><font face="Menlo" class=""><span style="font-size: 12px;" class=""> </span></font><span style="font-family: Menlo; font-size: 12px; font-variant-ligatures: no-common-ligatures;" class=""><font color="#4f8187" class="">ViewController { }</font></span></span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><span style="font-family: Menlo; font-size: 12px; color: rgb(187, 44, 162); font-variant-ligatures: no-common-ligatures;" class="">extension</span><span style="font-family: Menlo; font-size: 12px; font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures;" class=""><font color="#4f8187" style="font-family: Menlo; font-size: 12px;" class="">ViewController </font><font color="#bb2ca2" style="font-family: Menlo; font-size: 12px;" class="">named </font><font color="#d12f1b" class=""><font face="Menlo" class=""><span style="font-size: 12px;" class="">“Multi word description” </span></font></font></span></span></span><span style="color: rgb(79, 129, 135); font-family: Menlo; font-size: 12px;" class="">{ }</span></div><div style="font-family: Menlo; font-size: 12px; margin: 0px; line-height: normal;" class=""><br class=""></div><div style="font-family: Menlo; font-size: 12px; margin: 0px; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class="">For now, this is purely a documenting feature (i.e. Can’t refer to the extension name dynamically or statically in actual code). I think it plays much more naturally with Swift than requiring this to be in the comments and would work across all IDEs and make it easier for people to find a specific extension as well as making their code more self documenting.</div><div style="margin: 0px; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class="">Any thoughts?</div><div style="margin: 0px; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class="">Thanks,</div><div style="margin: 0px; line-height: normal;" class="">Brandon</div><div style="margin: 0px; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class=""><br class=""></div><div style="font-family: Menlo; font-size: 12px;" class=""><span style="font-family: Helvetica; font-size: 14px;" class=""><br class=""></span></div></div></span></div></div></body></html>