Cocoa at Tumblr:
Factories are a fairly well understood design pattern in software development. The benefits of using factories include:
This post will show the power of a few Swift features as well as of first-class functions.
- Abstracting constructors away from clients.
- Encapsulating data that clients do not need to know about.
- Allowing for more testable code by enforcing the idea of passing objects into initializers instead of referencing singletons directly.