<div dir="ltr">On 3 November 2017 at 18:08, Adam Kemp <span dir="ltr">&lt;<a href="mailto:adam_kemp@apple.com" target="_blank">adam_kemp@apple.com</a>&gt;</span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><br><div><div>1. You end up with a whole section of type aliases at the top of the file,</div></div></div></blockquote><div><br></div><div>i&#39;m putting those in a separate Platform.swift file</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><div><div>and as you read the file it’s hard to understand what those types actually represent.</div></div></div></blockquote><div><br></div><div>in the example above &quot;View&quot; - a very similar concept between macOS and iOS/tvOS/watchOS.</div><div>in case of doubts - command click is always at the finger tips.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><div><div>Which methods are you actually allowed to use? What should code completion show you? </div></div></div></blockquote><div><br></div><div>autocomplete shows the relevant methods on each platform correctly.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><div><div>2. The type alias is only useful when the naming of the methods/properties is identical and the sequence of calls you have to make is identical, which very often isn’t the case. You end up needing conditional compilation anyway for cases where you only need to make a call on one platform, or where the method you have to call is named slightly different or takes different arguments.</div></div></div></blockquote><div><br></div><div>if the differences are minute i&#39;m creating my own extension methods to make the difference non existent.</div><div><br></div><div>example: layer is optional on OSX and non optional on iOS. the difference is minute and i can make this difference non existent, e.g. by:</div><div><br></div><div><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(52,149,175)"><span style="color:rgb(4,51,255)">extension</span><span style="color:rgb(0,0,0)"> </span>UIView<span style="color:rgb(0,0,0)"> {</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)">    <span style="color:rgb(4,51,255)">var</span> viewLayer: <span style="color:rgb(52,149,175)">CALayer?</span> {</p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)">        <span style="color:rgb(4,51,255)">return</span> <span style="color:rgb(52,149,175)">layer</span></p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)">    }</p>
<p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)">}</p></div><div><br></div><div>and a similar thing on OSX, and afterwards i have single API on both platforms with no differences.</div><div><br></div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space">You end up needing conditional compilation anyway for cases where you only need to make a call on one platform, or where the method you have to call is named slightly different or takes different arguments. </div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"> </div></blockquote><div> </div></div><div>i rarely have to use conditional compilation and even when have to do so i normally hide it inside the relevant &quot;utility&quot; extensions, from then on i don&#39;t see anything &quot;conditional&quot; within the normal app sources.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><div><div>Out of the strategies I’ve seen used for cross-platform code this one was the most frustrating to work with in my experience.</div></div></div></blockquote><div><br></div><div>quite the contrary to me - the best possible experience with such an approach (during many years of experience ftm)</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><div><span class="gmail-"><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><div><div>My argument is that there should be no ledger in the first place. IMO you haven’t made the case for that requirement.</div></div></div></blockquote></div></div></div></blockquote></span></div></div></blockquote><div><div>the real-world example would be:</div><div><br></div><div>case 1. you have a single page of paper on hands saying: &quot;partial contract A. continued elsewhere. Blah, blah&quot;. you look around and within a multitude of papers on the table you managed to find another sheet of paper with &quot;partial contract A. continued elsewhere. Blah, blah&quot;. in order to find the whole thing you will have to look in all papers on your table, then in the shelve and then in the whole building (module boundaries)</div><div><br></div><div>case 2. you have a single page of paper on hands saying: &quot;contract A. continued with part B elsewhere. blah, blah&quot;. you look around and within a multitude of papers on the table you managed to find another sheet of paper with: &quot;part B of contract A, blah, blah&quot;. at that point you know that you found everything, don&#39;t need to look on the shelve or in the whole building.</div></div><div><br></div><div><div>case 3. you have a single page of paper on hands saying: &quot;contract A. continued with part B elsewhere. blah, blah&quot;. you look around the whole building and found no &quot;part B&quot;. at this point you know - something is lost, and act accordingly.</div></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><div><span class="gmail-"><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>i mean this:</div><div><br></div><div>class MyView: UIView {</div><div>    optional part Drawing</div><div>}</div><div><br></div><div>part Drawing of MyView { // **** forgot to include this into target</div><div>    override func drawRect(...) {</div><div>        .....</div><div>    }</div><div>}</div><div><br></div><div>the app compiles but doesn&#39;t work correctly.</div></div></div></div></blockquote><div><br></div></span><div>That example doesn’t make any sense.</div></div></div></blockquote><div><br></div><div>i don&#39;t see why (and I am not talking about cross platform code at this point). i have instances like these implemented via extensions in a day to day code. the split of the class into files was done merely for organising purposes, to keep file size manageable.</div><div><br></div><div>Mike<br></div><div><br></div></div></div></div>