An (highly elementary) introduction to VIPER
Transcript of An (highly elementary) introduction to VIPER
“It is not enough for code to work.”― Robert C. Martin, Clean Code: A Handbook of Agile
Software Craftsmanship
The search for the hollyarchitecture
The search for the holly
architecturemobile
Source:https://developer.apple.com/library/ios/documentation/General/Conceptual/DevPedia-CocoaCore/MVC.html
Source: Ugaya40 (Own work) [CC BY-SA 3.0 (http://creativecommons.org/licenses/by-sa/3.0)], via Wikimedia Commons
Source: blog.8thlight.com/uncle-bob/2012/08/13/the-clean-architecture.html
VIP(ER)
Source: https://medium.com/ios-os-x-development/ios-architecture-patterns-ecba4c38de52#.cqp3sgpj9
View
Display information to the user and detect user interaction
Presenter
Contains the UI related (UIKit independent) business logic.
Interactor
Performs business logic “Contains business logic related to the data (Entities) or networking, like creating new
instances of entities or fetching them from the server. For those purposes you’ll use some Services and Managers which are not considered as a part of VIPER module but
rather an external dependency.”
Entities
Plain data objects “Not all models (transport data structures) are Entities”
Router/Wireframe
The router/wireframe is what glues all of the other VIPER components to one
another and handles navigating from one view to another in the app.
Binding it all together
It’s up to you!
Conclusion
‣ Separation of concerns ‣ Increased testability ‣ Reusability
‣ Spagetti code ‣ Verbosity ‣ Onboarding time for new developers
Conclusion
‣ Separation of concerns ‣ Increased testability ‣ Reusability
‣ Spagetti code ‣ Verbosity ‣ Onboarding time for new developers
“There are two parts to learning craftsmanship: knowledge and work.
You must gain the knowledge of principles, patterns, practices, and heuristics that a craftsman
knows, and you must also grind that knowledge into your fingers, eyes, and gut by working hard and
practicing.”
― Robert C. Martin, Clean Code: A Handbook of Agile Software Craftsmanship”
Resources and further reading
‣ Ruby gem for generating VIPER files (https://github.com/rambler-ios/Generamba
‣ Clean architecture blog.8thlight.com/uncle-bob/2012/08/13/the-clean-architecture.html
‣ Testimonials http://www.outware.com.au/insights/ios-architecture-real-life-viper/ https://medium.com/ios-os-x-development/ios-architecture-patterns-ecba4c38de52#.cqp3sgpj9 https://medium.com/brigade-engineering/brigades-experience-using-an-mvc-alternative-36ef1601a41f#.srtvevutv
‣ Clean Swift http://clean-swift.com/clean-swift-ios-architecture/
Thank you!