Upgrade to Pro — share decks privately, control downloads, hide ads and more …

iOS App with VIPER Architecture

iOS App with VIPER Architecture

VIPER is an acronym for View, Interactor, Presenter, Entity and Router. It’s basically an approach that implements the Single Responsibility Principle to create a cleaner, more modular and testable structure for the iOS project. The idea behind this pattern is to isolate your app’s dependencies and balancing the delegation of responsibilities among the different layers.

Talk Video: https://www.youtube.com/watch?v=CQw2cDiRa_E

GitHub: https://github.com/suhitp/FlickrSearchApp

Twitter: https://twitter.com/suhit_rp
LinkedIn: https://in.linkedin.com/in/suhitt

Presented at Swift Mumbai Chapter 8 Meetup hosted by Eros Now
https://www.meetup.com/Swift-Mumbai/events/259194853/

Eeb061c8b2816b771920da1b3e7904a3?s=128

Swift India

April 13, 2019
Tweet

Transcript

  1. iOS App with VIPER Architecture Suhit Patil

  2. –objc.io “Good architecture is not what makes a product successful,

    but it does make a product maintainable and helps preserve the sanity of the people maintaining it!”
  3. Traits of good Architecture? •Consistent •Isolate Dependencies •Scalable •Testsable •Maintainable

  4. Model-View-Controller

  5. Massive View Controller •Networking •Business Logic •UI Configuration •Notifications •Observers

    •DataSource and Delegates etc.
  6. None
  7. Clean Architecture Ref: http://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html

  8. VIPER Architecture Viper Architecture

  9. View •UI layer which displays information forwarded by Presenter •Pass

    user actions / events to Presenter •UIViewController subclass with UI Elements like UITableView/ UICollectionView etc.
  10. Interactor •Implements business logic as specified by the application UseCase

    •Interacts with outer services like Networking, Database •Networking and Database are services which gets injected as Dependancies •Pass the data in the form of Entities to Presenter
  11. Entity •Model object which contains Data

  12. Presenter •Handles the presentation logic for the View •Prepares the

    ViewModel required in the format required by the view •Invokes methods on the Interactor •Passes events to router for navigation •Independent of UIKit
  13. Router •Responsible for navigation between Viper Modules

  14. Demo

  15. Cons •Highly increases the number of classes/protocols in the projects

    and complexity to create new modules. •Not much good examples and recommendations available online •Steep learning curve
  16. Questions

  17. Thanks