Just before reading this post, my professor tore apart my code for repeated logic and not following other coding conventions. Although his critiques were well-founded, I really appreciated reading this post by Harlan Kellaway about situations where it is better to go against "best practices". Many rules are meant to be broken – under the right circumstances. 👨🎓
So many tvOS apps require pin authentication, but there is no standard view controller for developers to just plug in. This custom class can easily be integrated into your app and accomplish everything you need, without reinventing the wheel. 🔒
I've run into this problem myself multiple times – there is an optional string that can be empty when non-nil (such as in UITextFields). Nathan Chan's answer to this problem is to extend String with a computed property that treats an empty string as nil, which is much more elegant than doing so manually every time.
Unless you have a formal computer science education, you may be hard-pressed to think of the factory design pattern, or how it would apply to real-life situations. In this post, John Sundell goes through an example of decoupling a network request from the state of the network request using this method, which helps to avoid problems down the road.