Swift Around the Web
"What it took me a while to get was that if we encounter an API or some source of objects that is giving us an optional X, we should probably want to turn it into a non-optional X as soon as we can. We want to push the “deal with the thing not existing” code out as far to the edges of our call graph as we can, and validate things as early as we can, and as close to the source of the objects as we can. This gives us more chance to deal with unexpected situations early before they become bad, and means that the bulk of the code doesn’t have to."
I've also adopted the use of principle on the UI level, using a VIewModel to validate the data before the final object is actually created.
I've honestly never thought of extending enums, but of course that is possible in Swift. And after realizing that Swift enums are essentially just more specified classes, it really doesn't seem as "loopy" to extend them as described in this blog post needed.
"Generics are lower down the pecking order. Remember, Swift likes to be as 'specific' as possible, and generics are less specific. Functions with non-generic arguments (even ones that are protocols) are always preferred over generic ones".
@AirspeedVelocity explains how to constrain your generics to make sure they're called. This reminds me of something I heard before about Swift generics - "the more you constrain them, the more you can do with them".