VIPER is an architectural pattern for structuring Android applications. It divides an app into distinct layers - View, Interactor, Presenter, Entity, and Router. The Presenter handles view logic and communication between the View and Interactor. The Interactor contains business logic. The View displays content from the Presenter. VIPER aims to make apps easier to understand, maintain, and test by separating concerns and reducing dependencies between layers. It is best for medium to large apps but may be overkill for small projects.
This chapter discusses programming for touchscreens and mobile devices in JavaScript. It covers using touch, pointer, and geolocation events to integrate mouse and touch interactions. It also provides ways to optimize mobile web apps, such as minimizing file sizes and loading scripts responsively. The chapter aims to help developers make their apps accessible and functional across different mobile platforms and input types.
React js use contexts and useContext hookPiyush Jamwal
The document discusses the useContext hook in React. It explains that hooks are special functions that start with "use" and are analogous to class component methods. The useContext hook allows components to access data from their parent context without having to pass props down through each level. Without useContext, data would need to be passed through props from the parent component to child components. With useContext, a Context Provider wraps components and provides a value that can be accessed using useContext in any child component without passing props.
This document discusses React hooks and how they enhance functional components. It explains that hooks allow functional components to maintain state and lifecycle methods like class components. The key hooks discussed are useState for managing state, useEffect for side effects like data fetching, and useCallback and useMemo for optimization. Custom hooks are also covered as a way to extract reusable logic. Overall, hooks improve on class components by making code more modular, reusable and easier to test.
MAX is a realtime messaging and activity stream engine that was originally designed for the Universitat Politècnica de Catalunya's social intranet. It provides a RESTful API with over 80 endpoints for multi-source user activity streams, asynchronous messaging and conversations. Key features include an activity stream, conversations, notifications, and the ability to aggregate external sources. It is fully deployable on-premises and addresses security and privacy concerns.
Command Query Responsibility Segregation and Event SourcingMitinPavel
This document discusses the Command Query Responsibility Segregation (CQRS) architectural pattern. CQRS separates read and write operations into different models, with commands modifying data and queries fetching data without side effects. Event sourcing is also discussed, where all state changes are stored as a sequence of events. The document provides code examples of implementing CQRS with commands, events, command handlers, and separate read and write models. Benefits mentioned include handling complexity, high performance, and using event sourcing for new reports and behavioral analysis from historical data.
테스트의 중요성에 대해서는 알고 있지만, 실제 프로젝트는 어떻게 적용해야 할지 모르는 어려운 경우가 많습니다. BDD를 적용하기 위해서 개발을 시작하기 전에 Use Case를 정리하고, Clean Swift의 각 컴포넌트를 구현하면서 Test Case까지 작성해본 실제 프로젝트 경험을 공유합니다.
EventBus is an open-source library that uses a publisher-subscriber pattern to enable communication between decoupled classes through simple method calls. Publishers post events to the EventBus which are then delivered to subscribed methods without dependencies between classes. Subscribers define subscriber methods annotated with @Subscribe to receive specific event types. Publishers can post events by calling EventBus' post method. EventBus supports features like delivery on different threads, sticky events, and configuration via its builder.
EventBus is a publish/subscribe event bus for Android that simplifies communication between components like activities, fragments, threads and services. It provides an alternative to traditional Android communication mechanisms like intents, handlers and broadcasts. With EventBus, components define events to publish, register as subscribers to receive events, and post events. This reduces the need for direct calls, callbacks and listener management between components.
Minicurso sobre AndroidAnnotations, GreenDAO, EventBus e CroutonRicardo Longa
O documento discute o uso de bibliotecas populares para Android como GreenDAO, EventBus, Crouton e Android Annotations. Ele fornece uma introdução a cada biblioteca, incluindo seus principais recursos e empresas que as usam, como Facebook e Pinterest. O documento também mostra exemplos de código para ilustrar o uso dessas bibliotecas.
Half way to clean architecture - Dmytro Voronkevych - Droidcon BerlinBadoo
There are many rumors surrounding Uncle Bob’s clean architecture. Many believe it’s a silver bullet that will solve every problem. This sounds great for anyone who wants to write a new application, but how do you safely transition a code base with ~100k lines of code and 5 years of history?
Our story is about an Android application with over 100 million installs, used by millions of people every day and is very profitable. The journey started with legacy code, then grew and transitioned into clean architecture. This was implemented all while working in a high-pressure environment with tough deadlines, constant changes and a lot at stake.
It all started as a j2me application, which rapidly grew, becoming legacy. It then required changes overall for improvement and maintenance. On top of the complications we faced, we then had to split the application, creating several new ones. Through this process we managed to improve our code by experimenting a lot, having many discussions, internal tech talks and also restructuring our team. Overall we learned a great deal!
I hope sharing these experiences will inspire other teams to start experimenting with architecture in a safe way.
This document discusses implementing Clean Architecture in iOS apps. It provides an agenda for a training on the topic, including understanding Clean Architecture concepts, implementing rules, and an example app called RealProgrammers. The first user story of displaying a list of programmers is implemented as an example, including defining the interactor, presenter and view components and their responsibilities, as well as the entity gateway.
The 3h workshop version of the 3d Advanced Architectures training (http://canonicalexamples.com/courses_android/#androidArch). I have delivered this one or the iOS counterpart in more than 20 cities of Europe and America. This is the latest version that shared in Minsk.
EventBus is an Android optimized publish/subscribe event bus. A typical use case for Android apps is gluing Activities, Fragments, and background threads together.
【Potatotips #26】Replace EventBus with RxJava/RxAndroidHiroyuki Kusu
This document discusses replacing the EventBus library with RxJava and RxAndroid for event handling in Android applications. It provides sample code for an RxEventBus class that can be used similarly to EventBus, posting and subscribing to events. It also discusses best practices like providing the RxEventBus as a singleton using Dagger 2 dependency injection.
Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...Svetlin Nakov
Few days ago I gave a talk about software architectures. My goal was to explain as easy as possible the main ideas behind the most popular software architectures like the client-server model, the 3-tier and multi-tier layered models, the idea behind SOA architecture and cloud computing, and few widely used architectural patterns like MVC (Model-View-Controller), MVP (Model-View-Presenter), PAC (Presentation Abstraction Control), MVVM (Model-View-ViewModel). In my talk I explain that MVC, MVP and MVVM are not necessary bound to any particular architectural model like client-server, 3-tier of SOA. MVC, MVP and MVVM are architectural principles applicable when we need to separate the presentation (UI), the data model and the presentation logic.
Additionally I made an overview of the popular architectural principals IoC (Inversion of Control) and DI (Dependency Injection) and give examples how to build your own Inversion of Control (IoC) container.
This document introduces the VIPER architecture pattern for structuring Android applications. It divides an app into distinct layers of View, Interactor, Presenter, Entity, and Router components. The View displays content from the Presenter and relays user input back. The Presenter handles view logic and requests data from the Interactor business logic layer. The Interactor encapsulates use cases. Entities contain model objects. And the Router manages navigation between screens. VIPER aims to make apps easier to understand, maintain, test, and develop by separating concerns into these layers.
Developing ASP.NET Applications Using the Model View Controller Patterngoodfriday
MVC provides a new web project type for ASP.NET that allows for more control over HTML and a more testable framework. It maintains a clean separation of concerns between models, views, and controllers and allows developers to easily extend or replace any component. MVC supports RESTful URLs, integrates well with existing ASP.NET features, and enables test-driven development through mockable abstractions.
Windows Store app using XAML and C#: Enterprise Product Development Mahmoud Hamed Mahmoud
This document provides an agenda and overview for a presentation on building Windows Store apps using XAML and C#. The presentation will demonstrate the Kona project, a sample Windows Store app, and how to build and test a Windows Store app using Team Foundation Build. It will also cover globalization, logging, MVVM pattern, navigation, and visual state support in Windows Store apps. The presentation aims to provide tips and best practices for enterprise product development of Windows Store apps.
The document discusses the ASP.NET MVC framework, which provides an alternative to ASP.NET Web Forms that allows for more control over HTML, cleaner separation of concerns, and easier testing of web applications. It emphasizes flexibility and extensibility, with pluggable controllers, views, models, and routes. The framework uses the MVC pattern with controllers handling user input and interfacing with models to access data, and views rendering user interfaces.
MvvmCross is a cross-platform MVVM framework that allows for sharing code and user interfaces across platforms. It uses the MVVM pattern with ViewModels, Models, and Views. ViewModels contain properties, commands, and notify of property changes. Models contain plain-old CLR object entities. Services can be used to access back-end services and events. The Application handles navigation between ViewModels and application states. The Navigator performs platform-specific navigation between Views. Runtime flow involves the EntryPoint instantiating Application and Navigator, then navigating between Views and ViewModels in response to user input and service events.
Developing your first application using FIWAREFIWARE
This document provides instructions for developing a first application using the FI-WARE platform. It discusses the FI-WARE architecture, including key components like the context broker and Wirecloud. It then describes how to create widgets using Wirecloud, connecting them to context broker and other FI-WARE services. The document also explains how to include IoT devices in a Z-Wave network and register them with the FI-WARE IoT backend.
This document provides an overview of modern Android development techniques including application architecture patterns like MVC, MVP and MVVM. It discusses topics like dependency injection with Dagger 2, reactive programming with RxJava, HTTP libraries like Retrofit and OkHttp, annotations, testing, using Kotlin and the future of Android development targeting the next billion users across more devices.
Reactive & Realtime Web Applications with TurboGears2Alessandro Molina
This document summarizes techniques for building reactive and real-time web applications using TurboGears and Python. It discusses how HTTP is changing to support real-time functionality through HTTP/2 and server pushing. Reactive frameworks that automatically update the web page on data changes are described. Solutions for real-time including polling, long polling, server-sent events, and websockets are covered. The document demonstrates using server-sent events and Socket.IO with TurboGears to build real-time applications. It also introduces Ractive.js and ToscaWidgets2 for adding reactivity to the client-side and integrating reactive widgets with TurboGears.
- Conductor is a framework that allows building View-based Android applications using a single Activity and handling screens via Controllers instead of Fragments. It aims to simplify app architecture and navigation.
- The main components are Controllers, which are wrappers for Views, and a Router that handles navigation and backstack operations between Controllers. ChangeHandlers manage animations during navigation.
- Conductor uses Fragments behind the scenes to retain Controller state but provides a simpler lifecycle model than Fragments. It also supports features like navigation, animations, MVP/MVVM patterns, and state restoration.
The document discusses the VIPER architecture pattern for structuring iOS applications. It begins by introducing the key components of a VIPER module: the View, Presenter, Interactor, Router, and Entity. It then provides examples of how each component is responsible for lifecycle management, event handling, data validation, routing, and other tasks. The document argues that VIPER increases testability, modularity, and code quality of iOS apps. It also promotes open sourcing example VIPER code on GitHub to help disseminate knowledge of this architecture.
The document discusses the Model-View-Presenter (MVP) architectural pattern. MVP separates an application into three main components: the model, the view, and the presenter. The model manages the behavior and data of the application, the view displays the UI and receives user input, and the presenter acts as a coordinator between the model and the view. It describes how MVP improves maintainability, testability and scalability compared to traditional approaches. It also provides examples of implementing MVP on Android and iOS platforms.
Do iOS Presentation - Mobile app architecturesDavid Broža
This document discusses mobile architecture and the MVP+ pattern. It recommends MVP+ as a highly testable architecture that is applicable across platforms. MVP+ uses components like views, presenters, navigators, and an assembly to wire everything together. It emphasizes keeping components independent, single responsibility, and making the architecture easy to learn, test, and evolve over time. Tests are provided as examples to verify different components are working as intended.
This document provides an overview of MongoDB Stitch, which is a serverless platform for building and hosting web and mobile backends. It discusses how Stitch can be used to handle user authentication and authorization, implement server-side rules, manage data access and synchronization, and define functions and triggers that run in response to events. Stitch aims to reduce the need for complex backend infrastructure by providing an integrated set of services for user management, data storage and syncing, and serverless logic.
A Separation of Concerns: Clean Architecture on AndroidOutware Mobile
Presented at YOW! Connected 2015 by Kamal Kamal Mohamed & Ryan Hodgman
As an Android developer, I want to deliver features without making compromises on code quality.
Scenario 1 - Given I am dealing with 1000+ line activities, When I have to develop a complicated feature, Then I waste time orienting myself and fixing bugs.
Scenario 2 - Given I have integrated a backend API directly into my app logic, When that API changes, Then I have to refactor large segments of unrelated logic in order to utilise the new API.
Scenario 3 - Given I have cleanly architected my application, When business/presentation/backend logic changes, Then I can easily update the relevant code without breaking unrelated features!
In this talk, two Android developers will present their take on what a cleanly architected app looks like and why it makes our lives easier. A well-defined separation of concerns has benefits not just for our sanity as developers, but also for the project workflow as it allows multiple developers to collaborate on a single feature with ease. We will be exploring how the domain-driven approach can improve code clarity, allow you to easily write tests, and provide a scalable infrastructure for you to quickly iterate on. Join us on our path of discovery as we discuss the advantages, drawbacks and implementation specifics in the context of a small sample project.
Developing your first application using FI-WAREFermin Galan
This document provides instructions for developing a first application using FI-WARE by connecting sensors to the FI-WARE IoT backend. It discusses connecting a basic Z-Wave sensor pack to the backend using FIGWAY software on a Raspberry Pi. The steps include including sensors in a Z-Wave network, editing registration and observation scripts to specify sensor IDs and callback URLs, registering sensors using fizway_register, and running fizway to interconnect sensors to the backend. Configuration files and ports for different sensor types like switches are also outlined. The goal is to enable sharing sensor data in FI-WARE's IoT Challenge HUB spreadsheet by connecting low-cost hardware to FI-WARE open APIs.
The document discusses frontend architecture and Jest testing. It covers goals of helping the team with architecture decisions, setup tests, and better unit tests. It then covers layers architecture with modules, components, services, and binding. It introduces Jest as a JavaScript testing framework and covers mocks, spies, stubs, and differences from Jasmine. It provides examples of unit testing Angular components in Jest with TestBed and avoiding side effects.
Through this presentation you will gain a good understanding of how the clean architecture pattern is implemented at Taxibeat. What issues the Android Taxibeat team has faced so far and what solutions we came up with. Of course, the benefits of clean architecture will also be discussed along with the way we managed to build two fast paced iterative apps that share functionality.
Portlets 2.0 Next Generation Portlet Applications
This document discusses portlets and the JSR 286 specification. It summarizes the key concepts of portlets, how they have evolved from JSR 168 to support inter-portlet communication and new features like resource serving. It also provides demos of public render parameters, events, and portlet federation capabilities.
Working effectively with ViewModels and TDD - UA Mobile 2019UA Mobile
The document discusses working effectively with ViewModels and test-driven development (TDD) in Android. It provides an overview of ViewModels and how they integrate with the Android lifecycle system using Lifecycle components and LiveData. It also covers tips for using ViewModels such as handling single emitted events, sharing data between fragments, RxJava support, and testing ViewModels with TestObserver and mock objects.
Thomas braun dependency-injection_with_robo_guice-presentation-finalDroidcon Berlin
The document discusses dependency injection (DI) using RoboGuice in Android applications. DI makes code more concise, modular, and easier to test by allowing classes to declare dependencies without knowing how they are satisfied. RoboGuice uses annotations to inject dependencies into activities and services. It allows for loose coupling, high cohesion, and centralized configuration through bindings. DI improves testability by increasing controllability, observability, and isolation of units under test.
Similar to Dmytro Zaitsev Viper: make your mvp cleaner (20)
Vladimir Lozanov How to deliver high quality apps to the app storeАліна Шепшелей
Mobile QA teams are responsible for thoroughly testing apps before release to ensure high quality. They use a variety of manual and automated testing methods at different stages of development. QA works closely with development and customer support to catch bugs, validate fixes, and improve the product based on user feedback. The goal is to deliver stable, bug-free apps through collaboration across teams.
Oleksandr Yefremov Continuously delivering mobile projectАліна Шепшелей
This document discusses best practices for continuously delivering mobile projects. It outlines a CI/CD workflow that includes running tests and manual QA on pull requests, notifying stakeholders, automatically generating changelogs and version bumps, preparing release artifacts, and publishing them to stores or S3. Key steps are running tests on pull requests, using strict PR naming conventions, notifying teams in Slack, automating versioning and publishing with scripts and Fastlane, and deploying beta builds to Fabric/Crashlytics. The full workflow aims to streamline mobile releases by automating repetitive tasks and integrating all steps.
Alexander Voronov Test driven development in real worldАліна Шепшелей
This document discusses test-driven development (TDD) practices. It covers topics like the benefits of cleaner interfaces and unbiased design when tests are written first. It also addresses challenges like introducing TDD to an existing codebase or team. Key points emphasized are starting simple with critical features, finding the lowest testable point, and making incremental changes to introduce tests and refactoring step-by-step. Continuous integration practices are also highlighted.
Apache Spark is an open-source parallel processing framework that supports in-memory processing to boost the performance of big-data analytic applications. We will cover approaches of processing Big Data on Spark cluster for real time analytic, machine learning and iterative BI and also discuss the pros and cons of using Spark in Azure cloud.
Valerii Iakovenko Drones as the part of the presentАліна Шепшелей
Drones, these are the tools that have densely entered to our life now. These are sources of geospatial information which form the basis and supplements many systems of monitoring and control. In detail, the speech will be about agribusiness.
This document provides an overview and agenda for an Apache HBase workshop. It introduces HBase as an open-source NoSQL database built on Hadoop that uses a column-family data model. The agenda covers what HBase is, its data model including rows, columns, cells and versions, CRUD operations, architecture including regions and masters, schema design best practices, and the Java API. Performance tips are given for client reads and writes such as using batches, caching, and tuning durability.
Dmitriy Kouperman Working with legacy systems. stabilization, monitoring, man...Аліна Шепшелей
About half of the developers, one way or another, faced with the legacy-projects. Not everyone can (and want) work with them. But with the right approach, such projects can be carried out with pleasure and even enthusiasm. We suggest that such a legacy of understanding, what are these project management techniques, practices, and explore the developers consider useful decisions: • Examples of optimization - it's worth a try; • Monitoring applications - JavaMelody; • Monitoring applications - logs and ELK (ELasticSearch + Logstash + Kibana); • Monitoring applications - Java Mission Control and Heap Dump Memory Analyzer Tool.
Anton Ivinskyi Application level metrics and performance testsАліна Шепшелей
It is important to understand how your code behaves in production, not just guess how it should behave. Know what takes time and what goes wrong. Measure it all. Be ready for the load with performance tests.
Anton Parkhomenko Boost your design workflow or git rebase for designersАліна Шепшелей
The document provides 4 tips to boost a designer's workflow: 1) Use Git to version and collaborate on design files, 2) Automate repetitive processes, 3) Be prepared for changes by using flexible components and responsive design, 4) Create prototypes to gather feedback early in the design process.
Andrew Veles Product design is about the processАліна Шепшелей
This document discusses product design and the product design process. It emphasizes that product design is about focus, thinking through every step of the process from initial ideas to implementation. This includes activities like creating portraits, user stories, specifications, site maps, flows, wireframes, prototypes, and UI design. It also notes that the goal is stable growth for the product over time, but that the solution designed may need to change as problems change. Examples are provided of redesigns for a mobile app, desktop app, and logo. The conclusion emphasizes that building the right features for the right users is more challenging than just building features.
Kononenko Alina Designing for Apple Watch and Apple TVАліна Шепшелей
Apple Watch and Apple TV apps are inherently different from other apps, in both form and function. You will learn watchOS and tvOS user experience foundations and design principles, get the quick overview of the best existing solutions and possible ways of extending your projects to this platforms.
Mihail Patalaha Aso: how to start and how to finish?Аліна Шепшелей
Mikhail Patalakha is a mobile ASO manager with experience managing over 50 successful projects. He provides tips for optimizing mobile app keywords and rankings, including opening the application, researching competitors' keywords, removing duplicates, getting new keywords from Google Keyword Planner, defining competition and traffic from services like SensorTower and ASOdesk, choosing keywords based on difficulty, and calculating approximate visitor numbers using a provided formula. His contact information is provided for further questions.
Gregory Shehet Undefined' on prod, or how to test a react appАліна Шепшелей
During the lecture we'll discuss the unit-testing of the interface. The stack of technologies: React (Redux, MobX), Mocha/Chai, React Tests Utils, Enzyme, Tape/Ava. Also, I will mention how we in Grammarly rewrite selenium to the unit tests, and how it works.
Alexey Osipenko Basics of functional reactive programmingАліна Шепшелей
During the report, we will develop incrementally construct primitives and algebra (in the worst case, just come up with a library interface) for the organization of interaction of the application with the mess in the real world. This approach will keep the application logic in the pure functions and declaratively associate external events with the necessary output.
And no React JS.
Step by step guide on building the multipurpose parser for scalable web data extraction.
Designing and usage of universal format for stripped web articles.
Format comparison with AMP(Google), Facebook Instant Articles and Apple News.
Roman Ugolnikov Migrationа and sourcecontrol for your dbАліна Шепшелей
The document discusses database migration and source control. It describes how database structure, data, and logic can change across versions. It recommends using tools like Liquibase and Flyway to manage database schema changes and keep the database schema in sync with code. These tools allow defining changes in migration files and rolling back changes if needed. The document also covers how the tools work, supported databases, file formats, preconditions, and provides a demo of using the tools for a sample database migration.
JHipster is a Yeoman generator used to create a Spring Boot and AngularJS project. It saves development time by including accepted practices and scaffolding for both design and runtime. The generator supports technologies like Spring Boot, AngularJS, Bootstrap, and MySQL. Developers can add additional functionality through JHipster modules and sub-generators. The generated projects include tools for testing, deployment to Docker, and integration with services like Elasticsearch.
Alex Theedom Java ee revisits design patternsАліна Шепшелей
Enter "Django Channels": new way of desinging and thinking about your application. It separates transport and processing concerns in typical Django project using combination of ASGI (Asynchronous Server Gateway Interface) and worker processes, enabling your application to be "event-oriented" and implement new workflows for processing your data. How does it work? What do you need to start? Is it even useful? Learn for yourself with this introductory talk.
8. MVP/MVC/MVVM is NOT an
Architecture!
It’s only responsible for the presentation layer delivery mechanism
9. Real-world Android app
● Hard to understand
● Hard to maintain
● The business logic is mixed in Activity/Fragment
● High coupled components
● MVC -> Massive View Controllers
● Hard and often impossible to test
11. Clean Architecture
● Independent of Frameworks
● Testable
● Independent of Database
● Independent of any external agency
● Independent of UI
15. What is VIPER?
● A way of architecting applications which takes heavy inspiration
from the Clean Architecture
● Divides an app’s logical structure into distinct layers of
responsibility
● Makes it easier to isolate dependencies
● Makes it easier test the interactions at the boundaries between
layers
● Eliminates Massive View Controllers
16. Main parts of VIPER
● View
● Interactor
● Presenter
● Entity
● Router
18. View
Displays what it is told to by the Presenter and relays user input back
to the Presenter
19. View
● Is passive
● Waits for the Presenter to give it content to display
● Never asks the Presenter for data
● Determines how the content is displayed
● Handles user interaction and input
● Simply delegates user’s actions to the Presenter
● Awaits for a response telling it what should be displayed next
20. internal interface CheeseViewCallbacks {
fun onNewCheese(cheese: Collection<CheeseViewModel>)
fun showError()
fun hideProgress()
fun showProgress()
}
Example of View
22. class CheeseView : ConstraintLayout, CheeseViewCallbacks {
@Inject internal lateinit var presenter: CheesePresenter
private lateinit var progressDialog : ProgressDialog
private lateinit var adapter : CheeseAdapter
/** ... */
override fun onNewCheese(cheese: Collection<CheeseViewModel>) {
adapter.setModels(cheese)
adapter.notifyDataSetChanged()
}
override fun showError() {
Toast.makeText(context, R.string.error, Toast.LENGTH_SHORT).show()
}
override fun hideProgress() = progressDialog.dismiss()
override fun showProgress() = progressDialog.show()
}
Example of View
23. Presenter
Contains view logic for preparing content for display (as received from
the Interactor) and for reacting to user inputs (by requesting new data
from the Interactor)
24. Presenter
● Knows about the content it maintains and when it should be
displayed
● Receives input events coming from the View
● Applies view logic over this data to prepare the content
● Tells the View what to display
● Sends requests to an Interactor
● Works like a bridge between the main parts of a VIPER module
● Receives the data structures coming from the Interactor
● Knows when to navigate to another screen, and which screen to
navigate to
25. class CheesePresenter(private val getCheeseInteractor: GetCheeseInteractor) {
var view: CheeseViewCallbacks? = null
var router: MainRouter? = null
/** ... */
fun fetchCheese(amount: Int) {
view?.showProgress()
getCheeseInteractor.execute({ cheese -> // onNext
view?.onNewCheeses(cheese)
view?.hideProgress()
},
{ // onError
view?.showError()
view?.hideProgress()
},
amount)
}
fun onItemClicked(model: CheeseViewModel) = router?.navigateToDetails(model)
}
Example of Presenter
31. data class Cheese(
val id : Long,
val name : String,
val price : Long,
val description : String,
val type : String,
val texture : String,
val fatContent : String,
val animalMilk : String,
val regionOfOrigin: String
)
Example of Entity
35. Router
● Responsible for passing data between screens
● Receives input commands from the Presenter
● Responsible for the navigation logic between modules
36. internal interface MainRouter {
fun navigateToDetails(model: CheeseViewModel)
fun navigateToPreferences()
fun navigateToRegistration()
}
Example of Router
37. class MainActivity : AppCompatActivity(), MainRouter {
override fun navigateToDetails(model: CheeseViewModel) {
startActivity(Intent(this, DetailsActivity::class.java).apply {
with(this) {
putExtra(DetailsActivity.NAME, model.name)
putExtra(DetailsActivity.CHECKED, model.isChecked)
}
})
}
override fun navigateToPreferences() {
startActivity(Intent(this, SettingsActivity::class.java))
}
override fun navigateToRegistration() {
supportFragmentManager.beginTransaction()
.replace(R.id.content, LoginFragment())
.commit()
}
}
Example of Router
38. Why should you use VIPER?
● It’s easier to track issues via crash reports
● The source code will be cleaner, more compact and reusable
● Adding new features is easier
● There are less conflicts with the rest of the development team
● It’s easier to write automated tests
39. When should you NOT use VIPER?
● It’s an overkill for small projects
● Causes an overhead when starting new projects
● MVP/MVC/MVVM-VIPER mix can cause headaches
● Lots of code all over the project