In this project I'm structuring my knowledge about modern architectural patterns,
showcasing the main features through a simple Movie app. The app makes use of
the Tmdb API which requires an API key. However, static
JSON
files are also included for quick usage.
- In Xcode, choose a target / architecture
- Build and run!
- Request an API key 🔑
- Insert your key in
TmdbAPIKey.plist
located at the root of/Architectures
- In Xcode, choose a target / architecture
- Build and run!
As I work through the architectures I will experiment with different setups while keeping the core principles of the architectures in mind. The project is designed with code readability and learning in mind, to use them in production may require performance optimisations or other changes. Some architectural aspects to consider:
🔹 Orthogonality: responsibilities, distribution, coupling etc.
🔹 Ease of use: how easy is it to set up and implement?
🔹 Testability: is it easy and convenient to test?
- Model
- Conceptual domain model, representing real state content
- Data layer objects, business logic (stores, managers)
- View
- Cells,
UIView
objects and subclasses - Send actions to Controller
- Cells,
- Controller
- Mediator between View and Model
- Delegate and datasource of almost everything
- Dispatching and canceling network requests
- Manages View lifecycle (tightly coupled)
- Model
- Conceptual domain model, representing real state content
- View
- Structure, layout, and appearance of what a user sees on the screen (
UIViewControllers
, cells,UIViews
) - Updates it’s state from the ViewModel by setting up bindings
- Forwards events to ViewModel
- Structure, layout, and appearance of what a user sees on the screen (
- ViewModel
- An abstraction of the view exposing public properties and commands
UIKit
independent representation of the View
- Binder
- A (reactive) databinding technology is key to the pattern. However, this simplistic app example achieves binding through callbacks.
- Model
- Conceptual domain model, representing real state content
- View
- Passive
UIViewControllers
, cells,UIViews
- May not know about Model or execute presentations
- Delegates user interactions to the presenter
- Passive
- Presenter
- Acts upon the model and the view
- Contains the logic to handle user interactions
- Retrieves data from the Model and formats it for display in the View
- View
- Displays what it is told to by the Presenter and relays user input back to the Presenter
- Interactor
- Contains business logic as specified by a use case
- The work done in an Interactor should be independent of any UI
- Presenter
- Contains View logic for preparing content for display (received from Interactor)
- Reacts to user inputs with data from Interactor
- Entity
- Conceptual domain model, representing real state content
- Only manipulated by the Interactor
- Routing
- Contains navigation logic for describing which screens are shown in which order
- Routing is shared between the Presenter and Wireframe
- Wireframe handles navigation transition animations