Badoo Dec 24, 2017

Singleton Service Locator Pattern and Testing in iOS

Article Summary

Bohdan Orlov tackles one of iOS development's most controversial debates: when Singletons and Service Locators are actually useful (and when they'll wreck your test suite).

This article examines why Singletons and Service Locator patterns are often labeled anti-patterns in iOS development. Orlov provides practical guidance on using these patterns while maintaining testable code, with specific Swift implementation examples.

Key Takeaways

Critical Insight

Use Singletons sparingly based on domain modeling and inject Service Locators explicitly through factories to keep your iOS code testable.

The article reveals a specific pledge developers can make about static variables that fundamentally changes how you architect iOS apps.

Recent from Badoo

Related Articles