A new library from Airbnb for declaratively building iOS apps
Overview
The article introduces Epoxy, a new library developed by Airbnb for declaratively building iOS applications. It discusses the challenges faced with imperative programming in UI development and how Epoxy simplifies the process by allowing developers to describe their UI goals rather than the steps to achieve them.
What You'll Learn
1
How to implement a declarative API for UICollectionView using Epoxy
2
Why moving from imperative to declarative programming improves UI development
3
How to use a fast O(N) diffing algorithm for batch updates in UI
Prerequisites & Requirements
- Familiarity with Swift and UIKit
- Experience in iOS app development
Key Questions Answered
What problems does Epoxy solve in iOS app development?
Epoxy addresses the complexity and crashes caused by imperative programming in UI updates. By allowing developers to describe their UI goals declaratively, it eliminates the need for tedious index path management, resulting in a smoother development experience and improved app stability.
How does Epoxy improve the developer experience compared to previous methods?
With Epoxy, developers transitioned from a net promoter score of -78 to +58 after implementing the library. This significant improvement highlights how the declarative approach reduces complexity and enhances satisfaction among engineers working on UI.
What is the role of the diffing algorithm in Epoxy?
The diffing algorithm, based on Paul Heckel’s fast O(N) algorithm, allows Epoxy to efficiently calculate the necessary updates between two states of the UI. This ensures that updates can be applied smoothly without the crashes associated with manual index path management.
How does Epoxy align with Android's Epoxy framework?
Epoxy for iOS was designed to align with the principles of Epoxy for Android, facilitating cross-platform collaboration. While the APIs differ due to platform specifics, both frameworks share a common philosophy aimed at simplifying UI development.
Key Statistics & Figures
Net promoter score before Epoxy implementation
-78
This score reflects the dissatisfaction among engineers with the previous imperative UI frameworks.
Net promoter score after Epoxy implementation
+58
This score indicates a significant improvement in developer satisfaction following the adoption of Epoxy.
Reduction in index path crashes
from hundreds of thousands to zero
This dramatic decrease showcases the effectiveness of Epoxy in stabilizing the UI update process.
Technologies & Tools
Framework
Epoxy
Used for declaratively building iOS app UIs.
UI Component
Uicollectionview
Epoxy is specifically designed to enhance the functionality of UICollectionView.
Key Actionable Insights
1Adopt Epoxy for your iOS projects to streamline UI development.Using Epoxy can significantly reduce the complexity of managing UI updates, allowing developers to focus on higher-level design rather than intricate details of index path management.
2Transition to a declarative programming model to improve team satisfaction.The shift from imperative to declarative programming not only enhances code clarity but also boosts developer morale, as evidenced by the increase in net promoter scores at Airbnb.
3Implement the fast O(N) diffing algorithm for efficient UI updates.This algorithm can help prevent crashes and ensure smooth animations during state changes, making it a crucial component of any modern UI framework.
Common Pitfalls
1
Failing to transition from imperative to declarative programming can lead to complex and fragile code.
Many developers may resist changing established patterns, but sticking to imperative methods can result in increased maintenance overhead and a higher likelihood of bugs.
Related Concepts
Declarative Programming
UI Development Patterns
Swift And Uikit Integration