Speaker Deck

Mixins over Inheritance - FrenchKit '16

by AliSoftware

Published September 23, 2016 in Technology

— My talk @ FrenchKit 2016. Video available here: https://youtu.be/BSn4jlunn4I

Embark in a journey with some Sci-Fi characters to discover how the Mixins & Traits pattern can help you better design your classes, avoid multiple-inheritance problems, and propose a protocol-oriented, Crusty-approved™ alternative to composition!

In this talk you'll discover what Mixins & Traits are, and how they can help avoid the problems otherwise brought by inheritance and be an interesting alternative to composition, by leveraging the Protocol-Oriented features of Swift.

We'll start by demonstrating the limitations of inheritance (and even composition) in some concrete examples, then present the concept of Mixins & Traits.

With the help of some fun examples and a bunch of Sci-Fi characters, we'll then see how this Mixins & Traits pattern can solve those problems, make your architecture more flexible, protocol-oriented… and allowing to factorize your code in a new way.

We'll finish the talk with a very concrete use case of Mixins that will allow you to get rid of String-based APIs like UITableViewCells,, UICollectionViews and UIStoryboard APIs, and make your code type-safe thanks to this Swift magic! ✨🎩

---

Read more on my blog posts containing detailed explanations about these topics:

* "Mixins over Inheritance": http://alisoftware.github.io/swift/protocol/2015/11/08/mixins-over-inheritance/
* "Using Generics to improve TableView cells": http://alisoftware.github.io/swift/generics/2016/01/06/generic-tableviewcells/