Using Swift generics in your own code
updated 4 months ago
This proposal has been withdrawn...
Generics allow us to write reusable code that can work with any type, that's quite powerful. The Swift standard library heavily relies on them, for example the
Array type can store any kind of elements of the same type and there is only one implementation for it.
Using generics for a collection type quickly comes to mind and seems to fit perfectly. However in the day-to-day life development it is not always obvious to see where we could use them and how they can improve our code.
This talk aims to show how generics can bring more than just code reusability through an example project, like:
- extracting the business logic from the view controller
- writing unit tests for the view controller
- making the view controller intent clearer
- improving performance safely
Emphasis will be put on the fact that this talk is presenting some ideas and not predefined rules to apply. Attendees will be encouraged to think on their own, on how generics could potentially help them improve their code base and solve some specific problems.