<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by IDAP on Medium]]></title>
        <description><![CDATA[Stories by IDAP on Medium]]></description>
        <link>https://medium.com/@idap?source=rss-58ad35675040------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*hMUnFEhRgq-rVWBd8dGH1w.png</url>
            <title>Stories by IDAP on Medium</title>
            <link>https://medium.com/@idap?source=rss-58ad35675040------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 23:50:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@idap/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Android arguments with Kotlin delegates]]></title>
            <link>https://medium.com/@idap/android-arguments-with-kotlin-delegates-d292269c99d2?source=rss-58ad35675040------2</link>
            <guid isPermaLink="false">https://medium.com/p/d292269c99d2</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[IDAP]]></dc:creator>
            <pubDate>Thu, 13 Jun 2019 12:39:34 GMT</pubDate>
            <atom:updated>2019-06-13T12:54:06.956Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*npcYeb9zZvifBhc5hFzeBA.jpeg" /></figure><p>In <strong>Android</strong>, <a href="https://developer.android.com/reference/android/os/Bundle"><strong>Bundle</strong></a> is used for sending data between <a href="https://developer.android.com/reference/android/app/Activity">Activities</a> and <a href="https://developer.android.com/reference/android/os/Bundle">Fragments</a>.</p><p>For example, to pass <em>userName</em> in Activity, we use Intent:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/93bf46de4d508c247b9adc7048141678/href">https://medium.com/media/93bf46de4d508c247b9adc7048141678/href</a></iframe><p>In a Fragment we can use Bundle directly:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3b8a485ee3ecab821f1fba4e087ce19d/href">https://medium.com/media/3b8a485ee3ecab821f1fba4e087ce19d/href</a></iframe><p>The following code allows us to extract passed argument in a fragment:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c1d958355f2a6c8f7b82b755a4a09179/href">https://medium.com/media/c1d958355f2a6c8f7b82b755a4a09179/href</a></iframe><p>In the same line, we have to write <em>userName </em>twice, and this is too much in Kotlin world.</p><p>What about the following variant:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2f773f9eba05031487b7a26a30ba8dd5/href">https://medium.com/media/2f773f9eba05031487b7a26a30ba8dd5/href</a></iframe><p>How we can implement it in Kotlin?</p><p>It can be done with <a href="https://kotlinlang.org/docs/reference/delegated-properties.html">delegated properties</a> that allow us to implement our own getters/setters.</p><p>Firstly, let’s implement <em>argumentDelegate()</em> for a certain type parameter, for example, a String. We can represent our delegate for Fragment as follows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/21b3c06ad288666e0ecb4848fc619e4d/href">https://medium.com/media/21b3c06ad288666e0ecb4848fc619e4d/href</a></iframe><p>This function returns an anonymous object that implements ReadOnlyProperty interface. This fact allows us to use this function together with Kotlin ‘by’ keyword in our fragment. Okay, well done, but what about all variety of types that could be passed to Bundle?</p><p>Of course, we need a <a href="https://kotlinlang.org/docs/tutorials/kotlin-for-py/generics.html">generic</a> version of our delegate. Using the <a href="https://kotlinlang.org/docs/reference/inline-functions.html#reified-type-parameters">reified</a> type parameter, it’s pretty easy to do:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e19675250b848181534e552bf6e028fb/href">https://medium.com/media/e19675250b848181534e552bf6e028fb/href</a></iframe><p>Since we also use it in Activity, we cannot focus on <em>Fragment::arguments</em> only. We could write an extension for Activity in the same way, but it would lead to code duplication and this is not that we had actually wanted. It doesn’t matter if you use Activity or Fragment, at the end data is saved in Bundle. So, we can extract a piece of code that works directly with arguments into a separate function.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8574a92ea14da1a08fc9d9b3038a5a38/href">https://medium.com/media/8574a92ea14da1a08fc9d9b3038a5a38/href</a></iframe><p>Now we can easily create an Activity extension for the same purpose:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ad5f41bd72bc288f711d1ee0a8d1496b/href">https://medium.com/media/ad5f41bd72bc288f711d1ee0a8d1496b/href</a></iframe><p>One more thing. In that case, each time, when you accessing to the userName, bundle: get will be called. That we need to improve is a fact that it would be great to use some kind of caching if we use extracted variables many times. For this case, Kotlin has another nice feature — <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/lazy.html">Lazy</a>. So let’s try with it:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6a388e3c6b3dc0f50421955e5def37db/href">https://medium.com/media/6a388e3c6b3dc0f50421955e5def37db/href</a></iframe><p>And as the last tiny edit, we have to do something in edge cases, like when no arguments were passed.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f727867a558108857f0f59d8be8b9f68/href">https://medium.com/media/f727867a558108857f0f59d8be8b9f68/href</a></iframe><p>All the code written above is available at <a href="https://github.com/idapgroup/ArgumentDelegate">ArgumentDelegate</a> library. Looking forward to getting your feedback.</p><p><em>By </em>Eugene Kotsogub<em>, </em>Android Developer<em> </em><a href="https://idapgroup.com/"><em>@ IDAP Group</em></a></p><p><em>Originally posted </em><a href="https://idapgroup.com/blog/android-arguments-with-kotlin-delegates/"><em>@IDAP Blog: </em>Android arguments with Kotlin delegates</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d292269c99d2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Swift: Optionals Without Conditionals]]></title>
            <link>https://medium.com/idap-group/swift-optionals-without-conditionals-7c40c2c1b449?source=rss-58ad35675040------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c40c2c1b449</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[IDAP]]></dc:creator>
            <pubDate>Wed, 01 Feb 2017 16:11:03 GMT</pubDate>
            <atom:updated>2017-02-02T07:06:45.684Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j1FzzXNbn6Ci25fvlvg4IQ.png" /></figure><p>Hello there my sweet fellow developers,</p><p>After I shared my innocent posts about <a href="http://blog.idapgroup.com/common-mistakes-noone-bothers-about-decomposition/">avoiding duplication</a>, <a href="http://blog.idapgroup.com/chainable-casting/">iflets and guards being unreadable</a> and <a href="http://blog.idapgroup.com/common-mistakes-noone-bothers-about-force-cast-unwrap-and-vars/">how bad implicit optionals and force casts are</a> I received a massive ~butth…~ feedback from the community of fellow reddittors. Some of them even claimed that I am incompetent, inconsiderate towards others, rapist and made calls to genocidal actions. Aside from those overexaggerations, what I noticed is that most of comments either labeled <em>Optional</em> as the entity used in conditional statements or the entity, that should lead to crashes. Another important stance I heard as an excuse for avoiding language features used for deduplication, is that the code would become less comprehensible.</p><p>I was a bit puzzled to say the least, as conditionals is the most difficult and lengthy way to use the Optionals. That’s because we have loads of functions in the standard library used specifically for optional processing. I’m not even mentioning <a href="https://github.com/typelift/Swiftz">SwiftZ</a>, <a href="https://github.com/typelift/Swiftx">SwiftX</a> and the likes, which turn an already powerful instrument into something truly amazing. And yep, they are incomprehensible in case you don’t know the basics behind them, as the methods for <em>Optional</em> handling originate from maths. But that’s not the reason to avoid them, that’s the reason to learn something new and improve.</p><p>So, lets start from the beginning. <em>Optional</em>, in case you don’t know, is the type, that represents availability or absence of value. As simple, as that.</p><p>Now, lets take a look some conventional Swift code written by the average dev:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/63a29bfe74b8293b465a3328392c1bc3/href">https://medium.com/media/63a29bfe74b8293b465a3328392c1bc3/href</a></iframe><p><strong>Disclaimer</strong>: <em>This is a sample code outlining the approach, same applies to other snippets. Pardon me, all my readers, who do actually understand that. You’d be shocked at how many people didn’t get, that my articles describe general approach, not specific use cases.</em></p><p>It’s pretty obvious, what the function does, but I’ll still explain. You pass two characters as bounds and receive the array of 1 character long strings in the range between those two characters.</p><p>The only thing I wrote in here, that is rarely used is <em>charToUInt</em>, as I wanted to avoid a bit of duplication. <em>charToUInt</em> is your typical function written in a closure way, as declaring such a small and easy to grasp function using <em>func</em> is a bit of an overkill in my opinion. You can read more about that kind of deduplication in my article:</p><p><a href="http://blog.idapgroup.com/common-mistakes-noone-bothers-about-first-order-functions/">Common mistakes no one bothers about - First Order Functions in Swift</a></p><p>Most of you, my dear readers, have either written or seen such code. But have you ever thought, that you could improve that code, make it more extensible flexible and less lengthy?</p><p>Now, before we proceed any further, I strongly suggest reading this awesome article about <a href="http://www.mokacoding.com/blog/functor-applicative-monads-in-pictures/">Monads, Functors and Applicatives</a>. While I won’t be using all of the concepts of the article to the fullest with <a href="https://github.com/typelift/Swiftz">SwiftZ</a>, you’ll still do yourself a favor, as you would surely become better SDE. Moreover it will simplify reading my article.</p><p>As a quick reference:</p><ul><li>Monads implement <em>func flatMap&lt;T&gt;(f: (T) -&gt; M&lt;T&gt;) -&gt; M&lt;T&gt;</em>, where <em>M</em> is Monad, wrapper around some value <em>T</em>;</li><li>Functors implement <em>func map&lt;T&gt;(f: (T) -&gt; T) -&gt; M&lt;T&gt;</em>, where <em>F</em> is Functor, wrapper around some value <em>T</em>.</li></ul><p>So, with all that knowledge in mind, lets take a look at how we could apply that knowledge to <em>conditionalCharacterStrings</em>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2bebeb569a82b3638eb1f2c5a1e66a6b/href">https://medium.com/media/2bebeb569a82b3638eb1f2c5a1e66a6b/href</a></iframe><p>If you are ready to burst with swearing, it’s the perfect time to close the article and write a comment about how horrible I am.</p><p>All the remaining readers must understand one important thing. It’s a different way of solving problems. It’s based on the concepts you are most probably not used to (otherwise, why would you read that article?). Once you understand them, you’ll understand them for life and you’ll’ be able to read all the code like that with ease. Why? Because <em>map</em> and <em>flatMap</em> are higher order functions from math, where you can process a function with another function and return a function as the result. They are as simple, as arithmetics. Remember, when you were still a schoolgirl/boy? Multiply and divide back then were also quite difficult, but now you use them without any problems. So, don’t be afraid.</p><p>Now, lets figure out line by line, what the hell is going on.</p><p>Bounds is just the way of applying <em>charToUInt</em> from the previous example to function inputs and unwrapping the <em>Optional</em> result of <em>first</em> call in the process. Why is it unwrapped? Its signature is: <em>func flatMap&lt;ElementOfResult&gt;(_ transform: (Element) -&gt; ElementOfResult?) -&gt; [ElementOfResult]</em>. This means, that <em>flatMap</em> in arrays, when the result of function passed as the parameter is <em>Optional</em>, automatically unwraps non-nil values and returns the new array with those values.</p><p>It could happen, that our inputs could have no representation in utf16, so we return an empty array in case one or both of the inputs could not be transformed in <em>UInt16</em>.</p><p><em>func min</em> in <em>Array</em> returns <em>Optional</em> as well. It’s because the <em>Array</em> could be empty. In that case there would be no minimum value in it. So, I just unwrap it with default value. Because of the count conditional check done previously the default would never be used, so it’s just a way to avoid implicit unwrapping.</p><p><em>range</em> is of type <em>UInt16</em>. It’s a numeric representation of our result, where each value corresponds to some character.</p><p>And now on to the meat of it all. <em>range.flatMap</em> behaves the same way, as <em>Array</em>, when the function passed to it as the parameter, returns an <em>Optional</em>. <em>UnicodeScalar($0)</em> actually returns us an <em>Optional</em>, so the first line of <em>return</em> statement just creates an <em>Array&lt;UnicodeScalar&gt;</em> of all the numbers in range, that could be presented as the <em>UnicodeScalar</em>.</p><p>The second line of <em>return</em> statement transforms <em>Array&lt;UnicodeScalar&gt;</em> into <em>Array&lt;String&gt;</em> by applying a transformer function to each of the elements of <em>Array&lt;UnicodeScalar&gt;</em>.</p><p>There are several things I dislike about that solution:</p><ul><li>Unisolated subscript usage could lead to crashes, if the code changes (out of bounds exception is not a joke), so extensive and exhaustive testing of all the cases is necessary;</li><li>Subscripts shadow the intentions behind the code;</li><li>A preemptive exit point breaks the processing flow;</li><li>Default value doesn’t look nice.</li></ul><p>So, in order to tackle these problems, lets improve the approach we have:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/944cedf4e8e8756e59d850fc571b9679/href">https://medium.com/media/944cedf4e8e8756e59d850fc571b9679/href</a></iframe><p><em>func toTuple</em> is a mere hack, as tuples in Swift are really limited as of now. They can’t conform to protocols, they can’t have functions of their own. In real world, the code generation approach used in <a href="https://github.com/typelift/Swiftz">SwiftZ</a> for <a href="https://github.com/typelift/Swiftz/blob/master/Sources/Kinds.swift">Kinds</a> and <a href="https://github.com/typelift/Swiftz/blob/master/Sources/Curry.swift">Curry</a> is preferred. Sadly, that’s the only way as of now. This function just returns a tuple of 2 first elements of <em>Array</em>, if the <em>Array</em> count is 2, otherwise it returns nil.</p><p>As for the return statement, it essentially does the same, as the previous example, with a few quirks:</p><ul><li>The result of processing is optional, so we default to empty result in case we couldn’t transform inputs into <em>UInt16</em> or there’s no min value in bounds;</li><li><em>bounds.toTuple().map</em> expects a function, that returns a value to be wrapped in <em>Optional</em> by <em>map</em> itself.</li></ul><p>The solution is hardly comprehensible in case you meet such approach for the first time. On the other hand, it is much more readable, when you are used to the approach, and is extensible and robust. It clearly expresses the intentions in terms of data processing. It avoids all the unnecessary duplication. The solution as a whole is a processing chain with no early fallbacks. The only unsafe code is isolated in a separate function, which needs extensive and exhaustive testing and could then be reused everywhere. It could even be written as a single chainable return statement, if swiftc wasn’t too dumb to solve the expression in a reasonable time.</p><p>So, it’s basically, up to you, if you would risk trying the approach. If you do, you’ll be amazed at how simple and short your code becomes, how simple it is to handle, modify and abstract out in case duplication arises.</p><p>That’s all, folks. Have a great day and stay DRY, no matter, where you are.</p><p><em>By Oleksa Korin, CTO @ </em><a href="http://www.idapgroup.com/"><em>IDAP Group</em></a></p><p><em>Connect with </em><strong><em>me</em></strong><em> on </em><a href="https://ua.linkedin.com/in/oleksandr-korin-48b67133/"><em>LinkedIn</em></a><em>, </em><a href="https://www.facebook.com/oleksa.korin"><em>Facebook</em></a><em>, </em><a href="https://twitter.com/trimmurrti"><em>Twitter</em></a></p><p><em>Follow </em><strong><em>IDAP</em></strong><em> on </em><a href="https://www.linkedin.com/company/idap-group"><em>LinkedIn</em></a><em>, </em><a href="https://www.facebook.com/IDAP.Group"><em>Facebook</em></a><em>, </em><a href="https://twitter.com/idapgroup"><em>Twitter</em></a></p><p><em>Originally posted @ </em><a href="http://blog.idapgroup.com/swift-optionals-without-conditionals"><em>IDAP Blog: Swift — Optionals without conditionals</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c40c2c1b449" width="1" height="1" alt=""><hr><p><a href="https://medium.com/idap-group/swift-optionals-without-conditionals-7c40c2c1b449">Swift: Optionals Without Conditionals</a> was originally published in <a href="https://medium.com/idap-group">IDAP</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Swift: Any can bite]]></title>
            <link>https://medium.com/idap-group/swift-any-can-bite-7782930b5169?source=rss-58ad35675040------2</link>
            <guid isPermaLink="false">https://medium.com/p/7782930b5169</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[IDAP]]></dc:creator>
            <pubDate>Tue, 24 Jan 2017 17:55:16 GMT</pubDate>
            <atom:updated>2017-01-24T17:55:16.817Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iDPIXZhHMgxS8cmsHsVJwA.png" /></figure><p><em>Any</em> and <em>Any?</em> in Swift are weird. We venture forth into the depth of unknown using Swift Reflection API as the basis for our research and find out some inconsistent behaviors for Swift casting API, when working with <em>Any</em>.</p><p>Recently, when playing around with Swift Reflection API, I stumbled upon a painful problem. Basically, when typecasting <em>Any</em> and <em>Any?</em> to protocols Swift just couldn’t help it and started screwing me in all my glory.</p><p>Without the further ado, here is the code, that ate me, raped me and killed what was left (in that specific order, mind you):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3ee9e16d27f81a9dc1f10943a739a620/href">https://medium.com/media/3ee9e16d27f81a9dc1f10943a739a620/href</a></iframe><p>You can read more about the <em>cast</em> function in my previous blog post:</p><p><a href="http://blog.idapgroup.com/type-inference/">Type Inference in Swift</a></p><p>If we run the code for <em>nested</em> property, the results would be as expected:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a78a822f59f78466129fa4f276d88aed/href">https://medium.com/media/a78a822f59f78466129fa4f276d88aed/href</a></iframe><pre>Type = Optional(Nested)<br>Nested<br>Nested Greetable<br>Nested Greetable as AnyObject</pre><p>The fun part starts, when we try to run the <em>printCasts</em> with <em>optionalNested</em> property:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1d8afd944ccba58f6c2e4c25102eee64/href">https://medium.com/media/1d8afd944ccba58f6c2e4c25102eee64/href</a></iframe><p>The results of the call are as weird as T-Rex trying to put my hat on while hiding in my wardrobe:</p><pre>Type = Optional(Optional(Nested))<br>Nested<br>Nested Greetable as AnyObject</pre><p>Swift managed to unwrap the <em>Optional&lt;Optional&lt;Nested&gt;&gt;</em> into nested, failed to do so, when unwrapping to <em>Greetable</em> protocol, to which <em>Nested</em> conforms, but managed to do the double optional unwrapping to protocol, when we’ve done an intermediate cast to <em>AnyObject</em>.</p><p>That is really bad at the most basic level, as we can’t use the same function for handling different values hidden by <em>Any</em> and we don’t have any non explicit way of knowing, what’s in there.</p><p>Please note, that the irregular behavior in here is the unwrapping of double optional. Value for <em>optionalNested</em> key is optional by itself, as the property is optional, and it is wrapped in another optional, when <em>first?</em> is called. For <em>optionalNested</em> none of the three conditions should have worked. This point is valid for explicit unwrapping from <em>Type??</em> to <em>Type</em>, where <em>Type != Any</em>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b95d416ca4d606162fd50fbfd9095629/href">https://medium.com/media/b95d416ca4d606162fd50fbfd9095629/href</a></iframe><p>This results in compiler error: <em>downcast from ‘Int??’ to ‘Int’ only unwraps optionals.</em> I tried playing around and found another interesting behavior:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a02d4618b4309bba6d5cb4a8d393864c/href">https://medium.com/media/a02d4618b4309bba6d5cb4a8d393864c/href</a></iframe><p>Prints <em>1</em>. So, it seems, like the compiler automatically unwraps, when casting to <em>Any?</em> and then if let casted to <em>Type</em> results in another unwrap.</p><p>So, how should we get around that? We could try doing the cast to <em>Optional&lt;Optional&lt;Greetable&gt;&gt;</em>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/be0b7ec7c00d4da2afb60d5ee66568a9/href">https://medium.com/media/be0b7ec7c00d4da2afb60d5ee66568a9/href</a></iframe><p>Sadly, that won’t do, as the compiler wouldn’t even consider compiling the thing. It would just return an error instead: <em>error: cannot downcast from ‘Any?’ to a more optional type ‘Greetable??’</em> That creeped me out, as <em>Any</em> could be of <strong>any</strong> type, meaning, that it could be an Optional, other wrapper (e.g. Either, Result, etc.) under the hood. Seems, like <em>Any</em> is just not defined well enough at that point in space and time (just imagine how lucky someone is in a parallel universe, where swiftc is well-written, doesn’t lag or crash).</p><p>Casting to <em>AnyObject</em> or <em>Any</em> is a hack and we should of course avoid that, as we could never be sure as to why it actually works and if future compiler versions would break it. A better(???) way would be to override the compiler checks and cast to appropriate types. We could do that by using the generic casting function:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/23c38bd492e3143fdbf9074adfb58d23/href">https://medium.com/media/23c38bd492e3143fdbf9074adfb58d23/href</a></iframe><p>This yields us better results in terms of types, but <em>Nested</em> is still being unwrapped from double optionals.</p><pre>Type = Optional(Optional(Nested))<br>Nested<br>Optional Greetable?</pre><p>But the best solution is to actually avoid <em>Any?</em> at all costs and be as explicit, as possible. Build your code around generics instead. On the other hand, there are not that much Swift APIs that return the result typed as <em>Any</em>, which could be both <em>Type</em> and <em>Optional&lt;Type&gt;</em> under the hood. So, if you use them, think in terms of proper language behavior (even, if this results in bloating your code). Don’t forget to cover everything <em>Any</em>-related with tests. I mean it, 100% test coverage of your code, library code, kid(s), wife(s)/husband(s), dog(s), cat(s), hamster(s), house(s), car(s), parent(s) and anything else you treasure is a must, as you never know, when the compiler would change it’s behavior. And don’t even try saying I didn’t warn you.</p><p>For my case, I just ignore the type system from the Swift Reflection API (namely, Mirror) based on <em>Any</em> and pretend I’m using ordinary possible values from my properties. Moreover, I explicitly unwrap the <em>Optional&lt;Any&gt;</em> to <em>Any</em> before casting just in case. This lets me avoid implicit double optional unwrapping and feel myself safe and secure (although I’m unsure this actually helps, as <em>betterPrintCasts</em> works the same way):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2dfeb36696bec22b8b0c28a8b099b7a1/href">https://medium.com/media/2dfeb36696bec22b8b0c28a8b099b7a1/href</a></iframe><p>results in the following output for <em>optionalNested</em> and <em>nested</em> property:</p><pre>Nested<br>Optional Greetable?</pre><p>That’s all, folks. Have a great day and stay DRY, no matter, where you are.</p><p><em>By Oleksa Korin, CTO @ </em><a href="http://www.idapgroup.com/"><em>IDAP Group</em></a></p><p><em>Connect with </em><strong><em>me</em></strong><em> on </em><a href="https://ua.linkedin.com/in/oleksandr-korin-48b67133/"><em>LinkedIn</em></a><em>, </em><a href="https://www.facebook.com/oleksa.korin"><em>Facebook</em></a><em>, </em><a href="https://twitter.com/trimmurrti"><em>Twitter</em></a></p><p><em>Follow </em><strong><em>IDAP</em></strong><em> on </em><a href="https://www.linkedin.com/company/idap-group"><em>LinkedIn</em></a><em>, </em><a href="https://www.facebook.com/IDAP.Group"><em>Facebook</em></a><em>, </em><a href="https://twitter.com/idapgroup"><em>Twitter</em></a></p><p><em>Originally posted @ </em><a href="http://blog.idapgroup.com/any-can-bite"><em>IDAP Blog: Any can bite</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7782930b5169" width="1" height="1" alt=""><hr><p><a href="https://medium.com/idap-group/swift-any-can-bite-7782930b5169">Swift: Any can bite</a> was originally published in <a href="https://medium.com/idap-group">IDAP</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Swift: Chainable Casting]]></title>
            <link>https://medium.com/idap-group/swift-chainable-casting-9dc958423aba?source=rss-58ad35675040------2</link>
            <guid isPermaLink="false">https://medium.com/p/9dc958423aba</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <dc:creator><![CDATA[IDAP]]></dc:creator>
            <pubDate>Mon, 23 Jan 2017 15:54:11 GMT</pubDate>
            <atom:updated>2017-01-23T16:10:16.972Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bwoMy8VQ1sd4eOudVo7MzA.png" /></figure><p>As I previously mentioned in Type Inference in Swift. I’m really tired of writing iflets and guards all over the place in my code.</p><p><a href="http://blog.idapgroup.com/type-inference/">Type Inference in Swift</a></p><p>In order to outline the problems lets imagine we have a <em>UITableView</em>, in which we need to present <em>UITableViewCell</em> subclasses from different inheritance hierarchies:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1ededf24bac765292d02c3562c3c3481/href">https://medium.com/media/1ededf24bac765292d02c3562c3c3481/href</a></iframe><p>Then, lets imagine, that Swift dev team invalidates iflets. As we all know, xCode Swift migration tools don’t work all the time and we have to rewrite the code manually for some cases. I had such transitions with Swift selectors and that was a huge pain in my butt. Moreover, in my opinion, iflets are against the DRY principle, which we all love and adore. The non-DRY code is really painful in terms of refactoring or rewriting, as you don’t have centralized access points.</p><p>In order to solve those problems, I prefer using my own solution:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/941be619b61ef279305b9924a81b1f73/href">https://medium.com/media/941be619b61ef279305b9924a81b1f73/href</a></iframe><p>We’ll get into the implementation details a bit later, but right now let me explain, why in my (not really) humble opinion, this solution is superior:</p><ul><li>It uses type inference;</li><li>It is expressive;</li><li>It is extensible;</li><li>It is robust.</li></ul><p>Yeah-yeah, I know, it makes the learning curve steeper for any newcomer, who is not aware of it. And yes, switch pattern matching could do the same, although the syntax would be a bit more verbose. But what it ultimately provides is, that as long, as I abide the interface, I could inject any behavior I want no matter, how Swift changes. Of course, it’s ultimately your decision, if you’d prefer to use it. I definitely prefer, as I can express the same logic in less key strokes and concentrate on the really important stuff (my ideas as to what I want to express, not how I want to express it).</p><p>So, how does it work under the hood?</p><p>Please, read through one of my previous articles about <em>cast</em> function. I’ll just outline its signature in here for the greater good, but you need to know, how to work with it:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0b49bcf5bce69ebecd5ffd5d9e109c63/href">https://medium.com/media/0b49bcf5bce69ebecd5ffd5d9e109c63/href</a></iframe><p>The guts of the solution I came up with are based on a <em>Castable</em> generic type:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c27ede7b9d29826a16ac67169c07552b/href">https://medium.com/media/c27ede7b9d29826a16ac67169c07552b/href</a></iframe><p>First of all, lets answer the most obvious question: “Why the hell do we use <em>switch</em> for one <em>case</em>? Why not <em>if case</em>?” The reason is actually simple. In order for Swift to handle such expressions without the default return, the function should be exhaustive and anything, except for switch covering all cases of enum is considered non-exhaustive by Swift. By exhaustive I mean, that all the cases of enum are handled. Moreover <em>if case</em> has a much worse syntax:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/be87ce81f93caec24d9937ff989f5fca/href">https://medium.com/media/be87ce81f93caec24d9937ff989f5fca/href</a></iframe><p>This fails with error <em>missing return in a function expected to return ‘NonExhaustive&lt;Wrapped&gt;’</em> Rewriting it with default return value as self could solve the problem:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/382a502da40c2858780b6a3423f77dd3/href">https://medium.com/media/382a502da40c2858780b6a3423f77dd3/href</a></iframe><p>But that’s just too much code for its own good.</p><p>The second question, that could probably arise is: “How is it working?”</p><p>You see, I consider <em>Castable</em> as a type can be procesed in 2 ways: matching and extraction.</p><ul><li>By matching I mean casting a wrapped value and if the cast succeeds, calling the function with the result of casting. To be able to chain operations I just return another <em>Castable</em> wrapping that same value.</li><li>Extraction just unwraps and returns a value.</li></ul><p>From my POV, creation of <em>Castable</em> by rewriting the same lines over and over again is not a good idea. Just imagine, that each time you want to use matching and extraction, you’d have to write <em>Castable.value(x).match(…</em> And that’s the most common use case, right? Sadly, we can’t just create a global function out of <em>Castable.value</em> initializer, as Swift doesn’t allow that for generics: <em>let castableFunction = Castable.value</em> results in <em>error: generic parameter ‘Wrapped’ could not be inferred note: explicitly specify the generic arguments to fix this issue</em>. Well, what can I say? Swiftc, you are drunk, go home.</p><p>So, in order to fix the thing I created several functions, that are the most common use — cases in my opinion:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3d1748b5af5a13ba48bb9f2bc3b81c4a/href">https://medium.com/media/3d1748b5af5a13ba48bb9f2bc3b81c4a/href</a></iframe><p>If you see any other use-cases or just want to add something, don’t hesitate to create the pull requests.</p><p>The library is readily available at cocoapods <em>IDPCastable</em> and is available on github as well: <a href="https://github.com/idapgroup/IDPCastable">IDPCastable</a>. You can check out the example in Tests/iOS, if you’d like.</p><p>That’s all, folks. Have a great day and stay DRY, no matter, where you are.</p><p><em>By Oleksa Korin, CTO @ </em><a href="http://www.idapgroup.com/"><em>IDAP Group</em></a></p><p><em>Connect with </em><strong><em>me</em></strong><em> on </em><a href="https://ua.linkedin.com/in/oleksandr-korin-48b67133/"><em>LinkedIn</em></a><em>, </em><a href="https://www.facebook.com/oleksa.korin"><em>Facebook</em></a><em>, </em><a href="https://twitter.com/trimmurrti"><em>Twitter</em></a></p><p><em>Follow </em><strong><em>IDAP</em></strong><em> on </em><a href="https://www.linkedin.com/company/idap-group"><em>LinkedIn</em></a><em>, </em><a href="https://www.facebook.com/IDAP.Group"><em>Facebook</em></a><em>, </em><a href="https://twitter.com/idapgroup"><em>Twitter</em></a></p><p><em>Originally posted @ </em><a href="http://blog.idapgroup.com/chainable-casting"><em>IDAP Blog: Chainable Casting</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9dc958423aba" width="1" height="1" alt=""><hr><p><a href="https://medium.com/idap-group/swift-chainable-casting-9dc958423aba">Swift: Chainable Casting</a> was originally published in <a href="https://medium.com/idap-group">IDAP</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Swift: Common mistakes no one bothers about — Optional force unwrap, vars and force cast]]></title>
            <link>https://medium.com/idap-group/swift-common-mistakes-no-one-bothers-about-optional-force-unwrap-vars-and-force-cast-f5e4b0c0ea54?source=rss-58ad35675040------2</link>
            <guid isPermaLink="false">https://medium.com/p/f5e4b0c0ea54</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[IDAP]]></dc:creator>
            <pubDate>Sat, 21 Jan 2017 20:45:32 GMT</pubDate>
            <atom:updated>2017-01-21T20:45:32.979Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F4P3Pcau5-2c-S5xLlOmlQ.png" /></figure><h3>Swift: Common mistakes no one bothers about — Optional force unwrap, vars and force cast</h3><p>Hello there, my sweet fellow developers,</p><p>In Swift, Apple introduced one really horrible thing, that breaks all the safety and sanity checks, as well, as eliminates usage of <em>Optional</em> as a safe type. This thing is the dark side of the force. It’s the operator <em>!</em>. I have several recommendations about using it:</p><ul><li>Don’t use <em>as!</em>;</li><li>Don’t use <em>variable!.doSomething()</em>;</li><li>Don’t use <em>let variable: Type!</em>.</li><li>Never use force operators;</li><li>Never ever use force operators;</li><li>You are not Jedi, don’t use force;</li><li>Neither are you a Sith, don’t use force;</li><li>Don’t, just don’t;</li><li>Kill everyone, who uses them, burn their houses and eat their kittens;</li><li>And more importantly, don’t you ever dare use them yourself.</li></ul><p>The biggest problem with force operators is that Swift isn’t ObjC with its duck typing, where you could get away with using one object, as another one, if they have the same interface. It’s not nil-safe, like ObjC as well. You can’t send messages to nil in Swift, while in ObjC messages to nil return nil (it’s still unsafe for messages returning structs even in ObjC).</p><p>What this means is, that you will never be sure about your Swift code, if you use the force. You won’t be able to reason about it either. Even, if you are sure, that your code with the force operator would behave as expected, it could change the other day, when you forget and fail to provide the variable of proper type or proper value. The main reason behind using force is that the developer is too lazy to write proper well-structured predictable code. Overcome your laziness and don’t use force operators.</p><p>So, just remember, each time you use force in Swift, you don’t leave any choice to God. He has to kill at least a puppy and a kitten. So, be good to animals, don’t use force.</p><p>And, for the last time, let me stress once again:</p><h3>DON’T USE FORCE OPERATORS</h3><p>No exceptions</p><p>That’s all, folks. Have a great day and stay DRY, no matter, where you are.</p><p><em>By Oleksa Korin, CTO @ </em><a href="http://www.idapgroup.com/"><em>IDAP Group</em></a></p><p><em>Connect with </em><strong><em>me</em></strong><em> on </em><a href="https://ua.linkedin.com/in/oleksandr-korin-48b67133/"><em>LinkedIn</em></a><em>, </em><a href="https://www.facebook.com/oleksa.korin"><em>Facebook</em></a><em>, </em><a href="https://twitter.com/trimmurrti"><em>Twitter</em></a></p><p><em>Follow </em><strong><em>IDAP</em></strong><em> on </em><a href="https://www.linkedin.com/company/idap-group"><em>LinkedIn</em></a><em>, </em><a href="https://www.facebook.com/IDAP.Group"><em>Facebook</em></a><em>, </em><a href="https://twitter.com/idapgroup"><em>Twitter</em></a></p><p><em>Originally posted @ </em><a href="http://blog.idapgroup.com/common-mistakes-noone-bothers-about-force-cast-unwrap-and-vars"><em>IDAP Blog: Common mistakes no one bothers about — Force cast, unwrap and vars</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f5e4b0c0ea54" width="1" height="1" alt=""><hr><p><a href="https://medium.com/idap-group/swift-common-mistakes-no-one-bothers-about-optional-force-unwrap-vars-and-force-cast-f5e4b0c0ea54">Swift: Common mistakes no one bothers about — Optional force unwrap, vars and force cast</a> was originally published in <a href="https://medium.com/idap-group">IDAP</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Swift: Common mistakes no one bothers about — Explicitness in property and function calls]]></title>
            <link>https://medium.com/idap-group/swift-common-mistakes-no-one-bothers-about-explicitness-567cb319fbea?source=rss-58ad35675040------2</link>
            <guid isPermaLink="false">https://medium.com/p/567cb319fbea</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[IDAP]]></dc:creator>
            <pubDate>Fri, 20 Jan 2017 11:57:35 GMT</pubDate>
            <atom:updated>2017-01-20T11:59:55.153Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h8XpMtBFshe1Gy8tZAxmrA.png" /></figure><h3>Swift: Common mistakes no one bothers about — Explicitness in property and function calls</h3><p>Hello there, my sweet fellow developers,</p><p>One thing I wanted to mention is, that Swift introduced implicitness in function and property calls (you can avoid calling self):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e2b797b235f6543ce2809cc63e827343/href">https://medium.com/media/e2b797b235f6543ce2809cc63e827343/href</a></iframe><p>We had such a thing for ivars in ObjC, but the illness has spread everywhere as of now. There are several points against using that language feature:</p><ul><li>The code without syntax highlighting is unreadable;</li><li>Even with the syntax highlighting, if you don’t know the code base perfectly, if there are global functions and variables and local functions and variables with same names as globals, it’s hard to derive, what is being called;</li><li>When used with properties, developers tend to forget, that multiple calls to properties should be cached in local variables, as they just don’t perceive the calls to properties as duplication without the explicit call.</li></ul><p>So, my advice to everyone is: don’t use shortcuts. Explicit and deduplicate the code instead of hiding the duplication visually, without hiding it logically. And yep, burying your head in sand like an ostrich, won’t do you any good, as properties are not ivars, no matter what you think, they could be or could become computationally expensive. So, just to rehearse, be explicit:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b770f8cbde49cac8657e22ceebf1fe85/href">https://medium.com/media/b770f8cbde49cac8657e22ceebf1fe85/href</a></iframe><p>That’s all, folks. Have a great day and stay DRY, no matter, where you are.</p><p><em>By Oleksa Korin, CTO @ </em><a href="http://www.idapgroup.com/"><em>IDAP Group</em></a></p><p><em>Connect with </em><strong><em>me</em></strong><em> on </em><a href="https://ua.linkedin.com/in/oleksandr-korin-48b67133/"><em>LinkedIn</em></a><em>, </em><a href="https://www.facebook.com/oleksa.korin"><em>Facebook</em></a><em>, </em><a href="https://twitter.com/trimmurrti"><em>Twitter</em></a></p><p><em>Follow </em><strong><em>IDAP</em></strong><em> on </em><a href="https://www.linkedin.com/company/idap-group"><em>LinkedIn</em></a><em>, </em><a href="https://www.facebook.com/IDAP.Group"><em>Facebook</em></a><em>, </em><a href="https://twitter.com/idapgroup"><em>Twitter</em></a></p><p><em>Originally posted @ </em><a href="http://blog.idapgroup.com/common-mistakes-noone-bothers-about-explicitness"><em>IDAP Blog: Common mistakes no one bothers about — Explicitness</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=567cb319fbea" width="1" height="1" alt=""><hr><p><a href="https://medium.com/idap-group/swift-common-mistakes-no-one-bothers-about-explicitness-567cb319fbea">Swift: Common mistakes no one bothers about — Explicitness in property and function calls</a> was originally published in <a href="https://medium.com/idap-group">IDAP</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Swift: Common mistakes no one bothers about — Macros and Directives]]></title>
            <link>https://medium.com/idap-group/swift-common-mistakes-no-one-bothers-about-macros-and-directives-80c8e1839f6c?source=rss-58ad35675040------2</link>
            <guid isPermaLink="false">https://medium.com/p/80c8e1839f6c</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[IDAP]]></dc:creator>
            <pubDate>Thu, 19 Jan 2017 15:34:55 GMT</pubDate>
            <atom:updated>2017-01-19T15:34:55.971Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZODC87FM9me75_lnZP_iCA.png" /></figure><h3>Swift: Common mistakes no one bothers about — Macros and Directives</h3><p>Hello there, my sweet fellow developers,</p><p>I have a story to tell you. Once upon a time I was bored. At that time I was playing around with my classes as usual, writing the tests for them in Kiwi. And I stumbled upon an interesting problem, I really wanted mocks for blocks to remove unnecessary boilerplate. Sadly, noone has opensourced that. So I thought, why don’t I write it? A pull request with some really interesting functionality wouldn’t hurt me or the community. So, I started implementing the code and found loads of strange things on my journey of refactoring and digging the runtime lib. Sadly, the story didn’t end well, as when I submitted the <a href="https://github.com/kiwi-bdd/Kiwi/pull/673">pull-request</a>, <a href="https://github.com/kiwi-bdd/Kiwi/issues/662#issuecomment-223775644">the maintainers decided to stop adding any new features with large functionality</a>. And I was like FFFFFFUUUUUUUUUUUUUUUUU…., because I started using that Kiwi feature in my projects prior to the pull-request being accepted, which means that I had to maintain the parallel branch. The story of my life. Oh well…</p><p>Still, during that journey I found one interesting thing scattered across the code:</p><pre>#if KW_TARGET_HAS_INVOCATION_EXCEPTION_BUG<br>    @try {<br>#endif // #if KW_TARGET_HAS_INVOCATION_EXCEPTION_BUG<br>...<br>#if KW_TARGET_HAS_INVOCATION_EXCEPTION_BUG<br>    } @catch(NSException *exception) {<br>        KWSetExceptionFromAcrossInvocationBoundary(exception);<br>    }<br>#endif // #if KW_TARGET_HAS_INVOCATION_EXCEPTION_BUG</pre><p>If you take a look at it, you’ll see, that it’s scattered all over the code, but it has a clear pattern. What this means to us is, that it should have been deduplicated. Why, because from what it looks like, this hack is not actual any more, but removing it from the codebase is really difficult, as the code is not isolated by any means. And, from what I gathered, that hack is unneeded any more (I don’t know the reason of its introduction, but tests don’t fail with it disabled, at least it seems like it, as I didn’t research deeply).</p><p>You shouldn’t consider this as a rant against Kiwi, as it’s not. Kiwi awesome and its developers and maintainers built a tool I used on the day to day basis for several years and am using it even now, when writing ObjC code.</p><p>After reading through the code I decided, that I don’t want to stumble upon such issues myself, so I added a guideline to make all the macro specific code isolated. If we apply that guideline to the bad code I wrote specifically for you:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/75b747bc998de57c01b5c78af8388db0/href">https://medium.com/media/75b747bc998de57c01b5c78af8388db0/href</a></iframe><p>This is not the only specific thing in swift out there. There loads of them, and some aren’t even marked with #. So, the better course of actions for such a code is to at least isolate it into separate function.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9744ff5596e23156eb734e7227200e76/href">https://medium.com/media/9744ff5596e23156eb734e7227200e76/href</a></iframe><p>However, that’s not the best idea as well. Why? We have different specific operations throughout our code, which leads us to the same problem of the <em>#if os(iOS)</em>, which is both duplication and is difficult to refactor. So, the better approach is to do it the same way I worked with injecting the closures and isolating such code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/94f46845b545f5711107203f4a275d2b/href">https://medium.com/media/94f46845b545f5711107203f4a275d2b/href</a></iframe><p>You can read more about the injection in previous rants, btw:</p><p><a href="http://blog.idapgroup.com/common-mistakes-noone-bothers-about-extensions/">Common mistakes no one bothers about - Extensions in Swift</a></p><p>That’s all, folks. Have a great day and stay DRY, no matter, where you are.</p><p><em>By Oleksa Korin, CTO @ </em><a href="http://www.idapgroup.com/"><em>IDAP Group</em></a></p><p><em>Connect with </em><strong><em>me</em></strong><em> on </em><a href="https://ua.linkedin.com/in/oleksandr-korin-48b67133/"><em>LinkedIn</em></a><em>, </em><a href="https://www.facebook.com/oleksa.korin"><em>Facebook</em></a><em>, </em><a href="https://twitter.com/trimmurrti"><em>Twitter</em></a></p><p><em>Follow </em><strong><em>IDAP</em></strong><em> on </em><a href="https://www.linkedin.com/company/idap-group"><em>LinkedIn</em></a><em>, </em><a href="https://www.facebook.com/IDAP.Group"><em>Facebook</em></a><em>, </em><a href="https://twitter.com/idapgroup"><em>Twitter</em></a></p><p><em>Originally posted @ </em><a href="http://blog.idapgroup.com/common-mistakes-noone-bothers-about-macros"><em>IDAP Blog: Common mistakes no one bothers about — Macros and Directives</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=80c8e1839f6c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/idap-group/swift-common-mistakes-no-one-bothers-about-macros-and-directives-80c8e1839f6c">Swift: Common mistakes no one bothers about — Macros and Directives</a> was originally published in <a href="https://medium.com/idap-group">IDAP</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Swift: Common mistakes no one bothers about — Extensions]]></title>
            <link>https://medium.com/idap-group/common-mistakes-no-one-bothers-about-extensions-76fa97c9de98?source=rss-58ad35675040------2</link>
            <guid isPermaLink="false">https://medium.com/p/76fa97c9de98</guid>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[IDAP]]></dc:creator>
            <pubDate>Wed, 18 Jan 2017 14:35:39 GMT</pubDate>
            <atom:updated>2017-01-19T15:37:22.285Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L3XSnD7ffANJUD4hRMoeQw.png" /></figure><h3>Swift: Common mistakes no one bothers about — Extensions</h3><p>Hello there, my sweet fellow developers,</p><p>When reviewing the code, I have 3 states with corresponding amount of WTFs per minute form worst to best:</p><ol><li>30…infinity -&gt; I want to kill the one responsible for introducing THAT to the world, he is the worst, even the most bloody dictators, like Stalin, Pol Pot or Hitler are kittens compared to him;</li><li>10..&lt; 30 -&gt; I like that guy/gal, (s)he is clever, we could work together and still survive, but yeah, everyone has his/her own flaws;</li><li>0..&lt;10 -&gt; That dev is awesome, I want to learn from him/her and bear his/her children.</li></ol><p>The perfect example of the code from the first category was a “little” class I’ve seen back in the olden days of iOS 3, that downloaded something from the API, parsed it and returned the result. Pretty simple, isn’t it? No one can’t spoil such a simple code, right? Wrong. The implementation was horrific. Do you think the guy used ASIHTTPRequest (there was no AFNetworking, as far, as I remember or AlamoFire back then)? Nope? Do you think the guy used a wrapper around <em>NSURLConnection</em>? Nope. But what did he use then? Well, he used <em>UIWebView</em> for downloading the JSON from the API. I can confess, there is blood on my hands, so I’m waiting for police to be incarcerated.</p><p>But there was another case some time ago, when the guy just hit 31 WTF/m. Everything was more or less fine, except for one thing, he was a fan of writing the code similar to the one below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bc5742c4df9fafd762e9708335c5ec25/href">https://medium.com/media/bc5742c4df9fafd762e9708335c5ec25/href</a></iframe><p>And that’s horrible. Just imagine forgetting to put either <em>beginUpdates</em> or <em>endUpdates</em> or just deleting them during refactoring. That would result in some headaches, especially, if we have several updates nested one into another. Moreover, projectwide, there were several such sections of code, which we can consider as duplication for our own good. But don’t be afraid, good old Oleksa has an advice for ya, it was passed through the generations of my family from before Christ and now I generously share it with you (tssssh, don’t tell anyone else): “Use categories/extensions and closures”:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3a5635b836e2ab356ec53b0c2c5d0b7a/href">https://medium.com/media/3a5635b836e2ab356ec53b0c2c5d0b7a/href</a></iframe><p>This extension is perfectly reusable and could be dragged from project to project or just podded (sorry, no Carthage here, Artsy and the Cocoapods are the best and I’m their biggest fan).</p><p>This sacred knowledge could also be applied to protocols:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/99f00141f6daf1d298c5520954e0fde1/href">https://medium.com/media/99f00141f6daf1d298c5520954e0fde1/href</a></iframe><p>We have protocol extensions at our hands in Swift and plain awesome macros in ObjC (although, that’s debatable and some of the devs could easily burn my car with me sitting inside for just mentioning them, still, take a look, if you are interested: <a href="https://github.com/idapgroup/IDPKit/tree/develop/Module/FoundationKit/Shared/Categories/NSLock">IDPLocking</a>), that could solve the problem of NSLock:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b849d6525da807fda2beae3c90be8d2b/href">https://medium.com/media/b849d6525da807fda2beae3c90be8d2b/href</a></iframe><p>Once again, same conveniences, as with <em>UITableView</em>. And no risks of forgetting to unlock. Moreover, thanks to protocol extensions we receive that behavior in all <em>NSLocking</em> compliant objects for free. And we have even taken it one step further and now we can actually get the result of function without using external variables. Why does it work? Because <em>Void</em> in Swift is a value, that equals empty tuple <em>()</em>.</p><p>This same idea could be applied in multiple ways not only in extensions though. As this approach is just a plain injection of behavior using functions, you could try using it for the greater good outside of extensions as well anywhere.</p><p>That’s all, folks. Have a great day and stay DRY, no matter, where you are.</p><p><em>By Oleksa Korin, CTO @ </em><a href="http://www.idapgroup.com/"><em>IDAP Group</em></a></p><p><em>Connect with </em><strong><em>me</em></strong><em> on </em><a href="https://ua.linkedin.com/in/oleksandr-korin-48b67133/"><em>LinkedIn</em></a><em>, </em><a href="https://www.facebook.com/oleksa.korin"><em>Facebook</em></a><em>, </em><a href="https://twitter.com/trimmurrti"><em>Twitter</em></a></p><p><em>Follow </em><strong><em>IDAP</em></strong><em> on </em><a href="https://www.linkedin.com/company/idap-group"><em>LinkedIn</em></a><em>, </em><a href="https://www.facebook.com/IDAP.Group"><em>Facebook</em></a><em>, </em><a href="https://twitter.com/idapgroup"><em>Twitter</em></a></p><p><em>Originally posted @ </em><a href="http://blog.idapgroup.com/common-mistakes-noone-bothers-about-extensions"><em>IDAP Blog: Common mistakes no one bothers about — Extensions</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=76fa97c9de98" width="1" height="1" alt=""><hr><p><a href="https://medium.com/idap-group/common-mistakes-no-one-bothers-about-extensions-76fa97c9de98">Swift: Common mistakes no one bothers about — Extensions</a> was originally published in <a href="https://medium.com/idap-group">IDAP</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Swift: Common mistakes no one bothers about — First Order Functions]]></title>
            <link>https://medium.com/idap-group/swift-common-mistakes-noone-bothers-about-first-order-functions-12808bdf8856?source=rss-58ad35675040------2</link>
            <guid isPermaLink="false">https://medium.com/p/12808bdf8856</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[IDAP]]></dc:creator>
            <pubDate>Tue, 17 Jan 2017 19:15:14 GMT</pubDate>
            <atom:updated>2017-01-19T15:37:33.609Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BXzlhevSpdvxXBkQqXZIZg.png" /></figure><h3>Swift: Common mistakes no one bothers about — First Order Functions</h3><p>Hello there, my sweet fellow developers,</p><p>Lets take a look at a completely different case of duplication. Suppose we want to perform serialization of an object:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6a325e5c706b507f692920700499e954/href">https://medium.com/media/6a325e5c706b507f692920700499e954/href</a></iframe><p>For the sake of clarity lets imagine that we want it specifically like that in several lines. We’ll discuss a better approach later on, but without adding such constraint it would be hard to show some useful tricks:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a8a199153aebf38f481166ccf7bbd6d7/href">https://medium.com/media/a8a199153aebf38f481166ccf7bbd6d7/href</a></iframe><p>That’s you average standard code for using the keyed archiver. The problem with it is, that it’s hard to refactor or extend it. Moreover, there is a duplication, as we call <em>encode</em> multiple times, which sucks in my humble (not really) opinion. And that duplication is not minor. Just imagine, that we’d want to use a different variable name and method for encoding. We’d have to rewrite the whole code to do so. A better solution would be to remember, that functions could capture the context around them:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e95f7d2cd3bf688b97776fb2187aea34/href">https://medium.com/media/e95f7d2cd3bf688b97776fb2187aea34/href</a></iframe><p>We just use a local higher order function in that case. So, if we want to change the method name and variable, that would be done in just one place, which would help us avoid confusion. The problem with this solution is, that we’d have to write such an encode in any encoding function around the project, and that’s an unacceptable case of the duplication. So, how about we make a factory of functions for encoding, that would catch the variable passed to them?</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e2b1ad0201f3cf291bf089c717b83603/href">https://medium.com/media/e2b1ad0201f3cf291bf089c717b83603/href</a></iframe><p>That’s much better. If Swift allowed generic functions without type specification to be put in variables, we could improve the code even more. However, it doesn’t allow that. One fundamental flaw in that approach is that we have to rely on external type specific functions and we don’t need that. Why? Because Swift functions are higher order. This means, that we can put them into variables, return them from functions or pass them as parameters to functions:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/05308f0270d40580205db13a5989ebb3/href">https://medium.com/media/05308f0270d40580205db13a5989ebb3/href</a></iframe><p>Sadly, that approach doesn’t always work. E.g., when the function is a struct mutating function or when the function has default parameters in it and several signatures with the same name (say, DispatchQueue.async signatures). Kudos to swiftc team, I hate you. Still, as we discussed in previous rants, calling a function multiple times in one scope means, that the solution wasn’t decomposed well enough:</p><p><a href="http://blog.idapgroup.com/common-mistakes-noone-bothers-about-decomposition/">Common mistakes noone bothers about - Swifty Decomposition</a></p><p>And we should definitely remember, that there are extensions, which allow us to add new ways of expressing our needs without bloating our code with helper classes (kudos to Java):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b1c4d9106f2e692deb10edddf4f6b4ed/href">https://medium.com/media/b1c4d9106f2e692deb10edddf4f6b4ed/href</a></iframe><p>BTW, this is a learning example, don’t forget to put the magic strings into constants, as we discussed in one of the previous blog posts:</p><p><a href="http://blog.idapgroup.com/common-mistakes-noone-bothers-about-consts/">Common mistakes noone bothers about - Swift Consts</a></p><p>I’ll discuss higher order functions some time later in more detail. Try them out, send in your cases of code to discuss or complain on your colleagues.</p><p>That’s all, folks. Have a great day and stay DRY, no matter, where you are.</p><p><em>By Oleksa Korin, CTO @ </em><a href="http://www.idapgroup.com/"><em>IDAP Group</em></a></p><p><em>Connect with </em><strong><em>me</em></strong><em> on </em><a href="https://ua.linkedin.com/in/oleksandr-korin-48b67133/"><em>LinkedIn</em></a><em>, </em><a href="https://www.facebook.com/oleksa.korin"><em>Facebook</em></a><em>, </em><a href="https://twitter.com/trimmurrti"><em>Twitter</em></a></p><p><em>Follow </em><strong><em>IDAP</em></strong><em> on </em><a href="https://www.linkedin.com/company/idap-group"><em>LinkedIn</em></a><em>, </em><a href="https://www.facebook.com/IDAP.Group"><em>Facebook</em></a><em>, </em><a href="https://twitter.com/idapgroup"><em>Twitter</em></a></p><p><em>Originally posted @ </em><a href="http://blog.idapgroup.com/common-mistakes-noone-bothers-about-first-order-functions"><em>IDAP Blog: Common mistakes no one bothers about — First Order Functions</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=12808bdf8856" width="1" height="1" alt=""><hr><p><a href="https://medium.com/idap-group/swift-common-mistakes-noone-bothers-about-first-order-functions-12808bdf8856">Swift: Common mistakes no one bothers about — First Order Functions</a> was originally published in <a href="https://medium.com/idap-group">IDAP</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Swift: Common mistakes no one bothers about — Decomposition]]></title>
            <link>https://medium.com/idap-group/swift-common-mistakes-noone-bothers-about-decomposition-289800e191f6?source=rss-58ad35675040------2</link>
            <guid isPermaLink="false">https://medium.com/p/289800e191f6</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[IDAP]]></dc:creator>
            <pubDate>Mon, 16 Jan 2017 15:27:25 GMT</pubDate>
            <atom:updated>2017-01-19T15:37:48.047Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4uxeJf-OXTpGRFyS-0RNhQ.png" /></figure><h3>Swift: Common mistakes no one bothers about — Decomposition</h3><p>Hello there, my sweet fellow developers,</p><p>The article is the continuation of the topic I recently talked about:</p><p><a href="http://blog.idapgroup.com/common-mistakes-noone-bother-about-bools/">Common mistakes noone bother about - Swift Bools</a></p><p>Recently I stumbled upon a gem among pieces of ~sh…~ code.</p><p>Let me introduce you to the most awesome code in all of its glory. You’ve seen it in many different faces, but it always boils down to something like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1eca3cf04ec76d47add79a0c6cc4ab18/href">https://medium.com/media/1eca3cf04ec76d47add79a0c6cc4ab18/href</a></iframe><p>It’s too early, wipe the sweat, even if you didn’t write such code. You shouldn’t consider the types and methods, just the idea of the code. And the idea is pretty simple. You set the same value into multiple properties or methods of different objects abiding the same interface.</p><p>First of all, the code is counter DRY and it just doesn’t use the <em>Bool</em> as <em>Bool</em>. There is a lot of duplication in here as well. So, a better way would be to refactor the code like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/632cdae09e528e095cba2822f902754b/href">https://medium.com/media/632cdae09e528e095cba2822f902754b/href</a></iframe><p>Right? Right? Wrong! We have deduplicated calls to <em>isUserInteractionEnabled</em> for same variables, but there are still 2 calls to <em>isUserInteractionEnabled</em> and there are two calls to <em>isOn</em>. Calling any property more than once in the scope of one function is a flaw by itself. Even, if your property is stored with potentially minimal overhead during access, it could change in the multithreaded environment, or it could become observable with some sophisticated observation code or even computed with some difficult computations. So, the best guideline is to never access the property or call the method more than once in a function, by properly decomposing the code and caching the method/property results:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/761da737809c092097c1f09f12caa50f/href">https://medium.com/media/761da737809c092097c1f09f12caa50f/href</a></iframe><p>That’s much better, but just imagine, that at some point in time the <em>isUserInteractionEnabled</em> would be renamed to <em>userInteractionEnabled</em>. Searching through the code in order to find the usages would be a pain. Lets try to avoid calling <em>isUserInteractionEnabled</em> multiple times to achieve an even better deduplication:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/00357655e15fcacfd122035250bff2d3/href">https://medium.com/media/00357655e15fcacfd122035250bff2d3/href</a></iframe><p>Whoa. That code is short. But is it good? On the visual level, there is no duplication. However, the duplication is still in there. It’s a logical duplication, as we call <em>isOn</em> in for each (twice for that particular case). So, lets cache it, shall we?</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5068f01754b2ec96cfceae8c43a57940/href">https://medium.com/media/5068f01754b2ec96cfceae8c43a57940/href</a></iframe><p>That’s much better. Now lets follow my advice and think about the future usages. I don’t have anything against YAGNI (you ain’t gonna need it) principle, I only propose to think about the decomposition, as small chainable functions is a much better way of writing, changing and reusing your ideas. Suppose we’d have to add another view, that we’d like to be disabled. Suppose, that we’d like to not only enable or disable the buttons but to change their background colors to the same color. Suppose, that we’d like to be able to enable/disable views in a completely different unrelated piece of code. The solution is simple and reusable at its core:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d2f6ba8922f931fd2d48dc1737644b29/href">https://medium.com/media/d2f6ba8922f931fd2d48dc1737644b29/href</a></iframe><p>Lets analyze it:</p><ul><li>We create the typealias to make the code more readable and avoid writing difficult syntax constructs. Yep, I consider writing <em>UIView</em> in square braces in several places of your code difficult, as it requires additional key strokes and autocomplete wouldn’t be able to help you;</li><li>We create the accessor to the array of views, if we want to change the views to be processed, we do that in just one access point and we avoid possible duplication;</li><li>We create enable, that could be used in different places of your code without the need to rewrite the same method or use the inheritance.</li></ul><p>It could be improved even more, if the properties were first order functions (they are under the compiler hood, just check the AST, but Swift won’t let us use them that way). We could, of course, emulate that behavior by passing the closure:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/78e89b831a146b0bba8afb2f1e1cd154/href">https://medium.com/media/78e89b831a146b0bba8afb2f1e1cd154/href</a></iframe><p>That’s just the matter of taste and a of a particular task. I don’t always use that approach, but I can’t say I avoid it all the time either. Just remember, for both cases, you’d have to deduplicate <em>forEach</em> in views in case you iterate them in multiple methods like that (a rough example, as, once again, based on the task, you could come up with a better way of solving the problem):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/90e24233da2044c1e7bb09255202f616/href">https://medium.com/media/90e24233da2044c1e7bb09255202f616/href</a></iframe><p>I’ll discuss higher order functions some time later in more detail, for now, just try the approaches I outlined above, you’ll be shocked at the ways you could apply them in order to simplify and deduplicate your code.</p><p>That’s all, folks. Have a great day and be DRY, no matter, where you are.</p><p><em>By Oleksa Korin, CTO @ </em><a href="http://www.idapgroup.com/"><em>IDAP Group</em></a></p><p><em>Connect with </em><strong><em>me</em></strong><em> on </em><a href="https://ua.linkedin.com/in/oleksandr-korin-48b67133/"><em>LinkedIn</em></a><em>, </em><a href="https://www.facebook.com/oleksa.korin"><em>Facebook</em></a><em>, </em><a href="https://twitter.com/trimmurrti"><em>Twitter</em></a></p><p><em>Follow </em><strong><em>IDAP</em></strong><em> on </em><a href="https://www.linkedin.com/company/idap-group"><em>LinkedIn</em></a><em>, </em><a href="https://www.facebook.com/IDAP.Group"><em>Facebook</em></a><em>, </em><a href="https://twitter.com/idapgroup"><em>Twitter</em></a></p><p><em>Originally posted @ </em><a href="http://blog.idapgroup.com/common-mistakes-noone-bothers-about-decomposition"><em>IDAP Blog: Common mistakes no one bothers about — Decomposition</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=289800e191f6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/idap-group/swift-common-mistakes-noone-bothers-about-decomposition-289800e191f6">Swift: Common mistakes no one bothers about — Decomposition</a> was originally published in <a href="https://medium.com/idap-group">IDAP</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>