Beyond MVC. Design Pattens, Architecture, FRP, and Dependencies Management. Flashcards
What design patterns are commonly used in iOS apps?
MVC, Singleton, Delegate, Observer
What is MVC?
- Models being NSObject subclasses or Core Data objects
- Views being UIView and UIViewControllers that draw things on screen
- Controller being application’s logic
MVC: Avantages
- Some architecture is better than none
2. It’s simple to understand and even novice developers can wrap head around
MVC: Disadvantages
- View controllers tend to be abused and given too much responsibility
- Falls short in edge cases. Where do you put a service object that does HTTP networking?
MVC: Alternatives
- MVVM can help extract some business logic and data out of view controllers and into view models
- SRP helps with setting firm boundaries for your code for object responsibilities
What is MVVM?
- A subset and extension of MVC
- Adds View models that play an important role in data presentation and delegating business logic triggered by the view layer
MVVM: Advantages
- fits nicely into existing MVC architectures
- more testable
- state decoupling, responsibility decoupling
What are the common layers of responsibility that an iOS application has?
UI Layer
Service Layer
Storage Layer
Business Logic Layer
What is the UI Layer responsible for?
Display UI elements on the screen and take user input in and delegate to rest of your app
What is the Service Layer responsible for?
All external communication your application has. ex: HTTP API client
What is the Storage layer responsible for?
Ultimate source of truth for the application
What is the Business Logic Layer?
Objects that use components and objects from other layers to achieve results and work for the user