具有 MVP 架构的 UIKit iOS 应用程序,利用 IoC 和 DI
清洁最有价值球员
战俘黑暗.mp4
Requirements:
Functional:
- Fetching and parsing data from API.
- Listing Data.
- Searching.
- Pagination.
- Navigation to Details view.
Non-Functional:
-
Performance:
- Caching images.
-
Scalability:
- Modularity.
-
Reliability:
- Unit tests.
Low-Level Design
Design Decisions
-
UI:
- UIKit
- MVP Architecture
-
Principals and Patterns:
- SOLID conformance:
- Features are separated into modules.
- UseCases for business logic.
- Utilizing IoC and DI.
- Coordinator pattern for navigation.
- SOLID conformance:
-
Dependency Manager:
- Swift Package Manager (SPM)
-
Dependencies:
- Kingfisher: Downloading and caching images from the web.
Notes:
- Design Patterns:
- Bridge Design Pattern ( and ) is used to avoid code duplication.
BaseVC
BasePresenter
- Adapter Design Pattern ( and ) is used to easily swap HTTP clients or Data Persistence if needed (ex. instead of ).
HTTPClient
WatchlistDataStore
Alamofire
URLSession
- Composite Reuse Principle (CRP) ( and ) is used to compose the .
DataSources
Delegates
ViewControllers
- An Automatic DI Container (Resolver or Swinject) could be used if the project got bigger.
- Repository Pattern could be used if local data storage is needed in the future.
- Bridge Design Pattern ( and ) is used to avoid code duplication.
- iOS APIs:
- DispatchGroup () is used to handle multiple async network calls.
SimilarMoviesUseCase
- Race Conditions are avoided in using a serial .
SimilarMoviesUseCase
DispatchQueue
- A Set is used over an Array in to achieve search time complexity.
WatchlistDataStore
O(1)
- DispatchGroup () is used to handle multiple async network calls.
- To achieve better UX:
ActivityIndicator
for each network called is used.Debouncer
is used to avoid unneeded search results and UI refreshes.- DarkMode and Landscape modes are supported.
- Errors are handled to avoid failing silently.
- Different placeholders are used for different image types (poster or cast).
- All the presenters are unit tested (15 tests in total).