SlideShare a Scribd company logo
@giorgionatili#DroidconBos - #MobileTea
Reactive MVP
@giorgionatili#DroidconBos - #MobileTea
About Me
+ Engineering Manager at Akamai (NG2 on desktop and
mobile)
+ Founder of Mobile Tea (www.meetup.com/pro/mobiletea)
+ Organizer of DroidCon Boston (www.droidcon-boston.com)
@giorgionatili#DroidconBos - #MobileTea
Agenda
+ Model View Presenter
+ Functional Reactive Programming
+ RxJava and Multi Threading
+ RxKotlin
@giorgionatili#DroidconBos - #MobileTea
Before We Start
+ There is a slide that is a fake
+ Catch it and tweet it (hashtag #DroidconBos)
+ Win a free ticket to Droidcon Boston
@giorgionatili#DroidconBos - #MobileTea
Model View Presenter
@giorgionatili#DroidconBos - #MobileTea
Model View
Presenter
@giorgionatili#DroidconBos - #MobileTea
Model View
Presenter
@giorgionatili#DroidconBos - #MobileTea
Model View 

Presenter
@giorgionatili#DroidconBos - #MobileTea
Original Design
@giorgionatili#DroidconBos - #MobileTea
Variations
@giorgionatili#DroidconBos - #MobileTea
The Presenter
@giorgionatili#DroidconBos - #MobileTea
Presenter Responsibilities
+ Manage the business logic
+ Handle the interaction between components
+ Orchestrator of behaviors and communication
@giorgionatili#DroidconBos - #MobileTea
Presenter Traits
+ A tiny class with a single responsibility
+ Optionally exposed trough an interface
+ Self independent and free from framework specific
constraints
@giorgionatili#DroidconBos - #MobileTea
Testable
+ Methods should be easy to be tested
+ Optionally (but strongly encouraged) should return a value
@giorgionatili#DroidconBos - #MobileTea
The View
@giorgionatili#DroidconBos - #MobileTea
View Responsibilities
+ Rendering data on the screen
+ Handle user interaction
+ Consume behaviors trough the presenter
@giorgionatili#DroidconBos - #MobileTea
View Traits
+ A class that deals only with the presentation layer
+ Always exposed trough an interface to the presenter
+ Self independent but able to handle frameworks constraints
@giorgionatili#DroidconBos - #MobileTea
The Model
@giorgionatili#DroidconBos - #MobileTea
Model Responsibilities
+ Manage the domain entities of a software
+ Facilitate the interaction with specific domain entities
+ Abstract domain objects in the context of a specific view
@giorgionatili#DroidconBos - #MobileTea
Model Traits
+ Decoupled and, when possible, framework agnostic
+ Designed to manage concurrency
+ Easy to test without external dependencies
@giorgionatili#DroidconBos - #MobileTea
Designing the Model
@giorgionatili#DroidconBos - #MobileTea
Behaviors
+ Identify software behaviors
+ Group functionality by behavior
+ Consistent returned data types
@giorgionatili#DroidconBos - #MobileTea
Value Objects
+ Should represent a value in your system
+ Should describe the characteristics of a thing
+ Equality is not based upon identity
+ Should be immutable
@giorgionatili#DroidconBos - #MobileTea
Entities
+ Should have a unique identity
+ Should delegate behaviors to value objects and aggregates
@giorgionatili#DroidconBos - #MobileTea
Aggregates
+ A cluster of associated objects that are treated as a unit for
the purpose of data change
+ A way to move as much as possible of the behavior away
from the Entities within the aggregate -> into Value Objects
+ A place to define the consistency rules of Value Objects
@giorgionatili#DroidconBos - #MobileTea
Repositories
+ A mechanism for encapsulating storage, retrieval, and
search behaviors which emulates a collection of objects
+ Usually injected in a Service
@giorgionatili#DroidconBos - #MobileTea
Equence
+ Prevent race conditions and data collisions
+ Unify domain objects in aggregates
@giorgionatili#DroidconBos - #MobileTea
Services
+ Services are always exposed as an interface, not for
“swappability” or testability, but to expose a set of cohesive
operations
+ Domain services are the coordinators, allowing higher level
functionality between many different smaller parts.
@giorgionatili#DroidconBos - #MobileTea
@giorgionatili#DroidconBos - #MobileTea
Functional Reactive
Programming
@giorgionatili#DroidconBos - #MobileTea
In a Nutshell
+ FRP is a programming paradigm
+ It focuses on reacting to streams of changes (data and
events)
+ It favors function composition, avoidance of global state and
side effects
@giorgionatili#DroidconBos - #MobileTea
FRP Use Cases
+ Processing user (tap, swipe, etc.) and system events (GPS,
gyroscope, etc.)
+ Responding and processing any IO event (asynchronously)
+ Handling events and data pushed from other sources
+ Many, many, many others! : )
@giorgionatili#DroidconBos - #MobileTea
Observable<T>
+ An Observable represents a flowing stream of values
+ UI events
+ Data processed in background
+ The most similar abstraction is Iterable<T>
@giorgionatili#DroidconBos - #MobileTea
Pull vs Push
+ Observable is push based, it decides when to emit values
+ Iterable is pull based, it sits until the some ask for the
next() value
@giorgionatili#DroidconBos - #MobileTea
Pull vs Push
@giorgionatili#DroidconBos - #MobileTea
Hot vs Cold Observables
+ A cold Observable is entirely lazy
+ Hot Observables might already be emitting events no
matter how many Subscribers they have
+ Hot Observables occur when we have absolutely no
control over the source of events (aka taps)
@giorgionatili#DroidconBos - #MobileTea
@giorgionatili#DroidconBos - #MobileTea
RxJava
@giorgionatili#DroidconBos - #MobileTea
In a Nutshell
+ It’s an implementation of the Reactive Extensions (Rx) on
the JVM
+ In RxJava, events are modeled as observable streams to
which observers are subscribed
+ Implement methods composibility to improve the
management of complicated workflows
@giorgionatili#DroidconBos - #MobileTea
Create an Observable
@giorgionatili#DroidconBos - #MobileTea
Subscribe to Observable
@giorgionatili#DroidconBos - #MobileTea
Multithreading
+ The ability to run several functions of a single program
simultaneously
+ Predominantly by utilizing several processors, but
potentially, by time-sharing their resource requirements
@giorgionatili#DroidconBos - #MobileTea
Parallelization
+ A common question about RxJava is how to achieve
parallelization, or emitting multiple items concurrently from
an Observable
+ This definition breaks the Observable contract which
states that onNext() must be called sequentially and
never concurrently
@giorgionatili#DroidconBos - #MobileTea
RxJava Implementation
+ Version 2.0.5 introduced the ParallelFlowable API that
allows parallel execution of a few select operators such as
map, filter, concatMap, reduce and so on
+ Earlier versions introduced observeOn and subscribeOn
to model parallel computations
@giorgionatili#DroidconBos - #MobileTea
subscribeOn()
+ The method subscribeOn() allows you to move the
execution of the Observable code into another thread and
with an specific behavior
@giorgionatili#DroidconBos - #MobileTea
observeOn()
+ The observeOn() method allows to specify where to
execute the functions provided in the subscribe() one
@giorgionatili#DroidconBos - #MobileTea
Schedulers
+ immediate(), creates and returns a Scheduler that executes work immediately on
the current thread
+ trampoline(), creates and returns a Scheduler that queues work on the current
thread to be executed after the current work completes
+ newThread(), creates and returns a Scheduler that creates a new Thread for each
unit of work
+ computation(), creates and returns a Scheduler intended for computational work
+ io(), creates and returns a Scheduler intended for 10-bound work (unbounded,
multiple threads)
@giorgionatili#DroidconBos - #MobileTea
@giorgionatili#DroidconBos - #MobileTea
Kotlin
@giorgionatili#DroidconBos - #MobileTea
Why Kotlin
+ Data classes
+ Inferred datatypes
+ Nullable types
+ Arguments default value
+ Lambda expression and “elvis” operator
+ Extension functions
@giorgionatili#DroidconBos - #MobileTea
Kotlin and the JVM
@giorgionatili#DroidconBos - #MobileTea
Nullable Types
+ Nothing can be null in Kotlin until is not specified
@giorgionatili#DroidconBos - #MobileTea
Data Classes
@giorgionatili#DroidconBos - #MobileTea
Custom Getters
@giorgionatili#DroidconBos - #MobileTea
Lambdas
+ Small chunks of code that can be passed to other functions
+ The ability to treat functions as values is part of the
functional programming paradigm
@giorgionatili#DroidconBos - #MobileTea
Inline Functions + Default
Values
+ Functions can be declared outside of a class and imported
in others
+ Arguments can have default values reducing the number of
methods overloads
@giorgionatili#DroidconBos - #MobileTea
High Order Functions
+ A higher-order function is a function that takes functions as
parameters, or returns a function
@giorgionatili#DroidconBos - #MobileTea
@giorgionatili#DroidconBos - #MobileTea
Clean Architecture
@giorgionatili#DroidconBos - #MobileTea
Demo
@giorgionatili#DroidconBos - #MobileTea
Questions & Answers
@giorgionatili#DroidconBos - #MobileTea
Thanks!

More Related Content

PPTX
Why Domain-Driven Design and Reactive Programming?
VMware Tanzu
 
PDF
Category Theory made easy with (ugly) pictures
Ashwin Rao
 
PDF
Building Scalable Stateless Applications with RxJava
Rick Warren
 
PDF
Isomorphic Reactive Programming
Giorgio Natili
 
PDF
What we can learn from hackers (about the definition of work)
🌍 Job van der Voort
 
PDF
Mixité dans le monde des WebComponents - DevFest Toulouse - 2017-09-27
Horacio Gonzalez
 
PDF
Managing Chaos In Production: Testing vs Monitoring
Robert Treat
 
PPTX
Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)
Alina Vilk
 
Why Domain-Driven Design and Reactive Programming?
VMware Tanzu
 
Category Theory made easy with (ugly) pictures
Ashwin Rao
 
Building Scalable Stateless Applications with RxJava
Rick Warren
 
Isomorphic Reactive Programming
Giorgio Natili
 
What we can learn from hackers (about the definition of work)
🌍 Job van der Voort
 
Mixité dans le monde des WebComponents - DevFest Toulouse - 2017-09-27
Horacio Gonzalez
 
Managing Chaos In Production: Testing vs Monitoring
Robert Treat
 
Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)
Alina Vilk
 

Similar to Reactive MVP - Giorgio Natili - Codemotion Rome 2017 (20)

PDF
Clear the UIViewController Mess
Giorgio Natili
 
PDF
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB
 
PPTX
Mobile-First Indexing or a Whole New Google - Digitalzone 2018
MobileMoxie
 
PPTX
MongoDB.local Atlanta: MongoDB Mobile: Bringing the Power of MongoDB to Your ...
MongoDB
 
KEY
MVC in Sencha Touch & ExtJS
Aaron White
 
PDF
A realtime infrastructure for Android apps: Firebase may be what you need..an...
Alessandro Martellucci
 
PDF
MongoDB.local Austin 2018: MongoDB Mobile: Bringing the Power of MongoDB to Y...
MongoDB
 
PDF
Reactive Programming with JavaScript
Codemotion
 
PDF
The Little Shop of TDD Horrors
FITC
 
PPTX
MongoDB Mobile: Bringing the Power of MongoDB to Your Device
MongoDB
 
PPTX
Unity and Azure Mobile Services using Prime31 plugin
David Douglas
 
PPTX
Production Testing Through Monitoring
DevOpsDays Baltimore
 
PPTX
MongoDB.local Seattle 2019: MongoDB Mobile: Bringing the Power of MongoDB to ...
MongoDB
 
PPTX
MongoDB Mobile: Bringing the Power of MongoDB to Your Device
MongoDB
 
PPTX
MongoDB.local Sydney 2019: MongoDB Mobile: Bringing the Power of MongoDB to Y...
MongoDB
 
PPTX
MongDB Mobile: Bringing the Power of MongoDB to Your Device
Matt Lord
 
PDF
MongoDB.local Berlin: MongoDB Mobile
MongoDB
 
PDF
Cindy Krum-Digitalzone18
Zeo
 
PDF
Hello Flutterの次におさえたいFlutterのポイント
Kenichi Kambara
 
PDF
The Little Shop of TDD Horrors
Giorgio Natili
 
Clear the UIViewController Mess
Giorgio Natili
 
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB
 
Mobile-First Indexing or a Whole New Google - Digitalzone 2018
MobileMoxie
 
MongoDB.local Atlanta: MongoDB Mobile: Bringing the Power of MongoDB to Your ...
MongoDB
 
MVC in Sencha Touch & ExtJS
Aaron White
 
A realtime infrastructure for Android apps: Firebase may be what you need..an...
Alessandro Martellucci
 
MongoDB.local Austin 2018: MongoDB Mobile: Bringing the Power of MongoDB to Y...
MongoDB
 
Reactive Programming with JavaScript
Codemotion
 
The Little Shop of TDD Horrors
FITC
 
MongoDB Mobile: Bringing the Power of MongoDB to Your Device
MongoDB
 
Unity and Azure Mobile Services using Prime31 plugin
David Douglas
 
Production Testing Through Monitoring
DevOpsDays Baltimore
 
MongoDB.local Seattle 2019: MongoDB Mobile: Bringing the Power of MongoDB to ...
MongoDB
 
MongoDB Mobile: Bringing the Power of MongoDB to Your Device
MongoDB
 
MongoDB.local Sydney 2019: MongoDB Mobile: Bringing the Power of MongoDB to Y...
MongoDB
 
MongDB Mobile: Bringing the Power of MongoDB to Your Device
Matt Lord
 
MongoDB.local Berlin: MongoDB Mobile
MongoDB
 
Cindy Krum-Digitalzone18
Zeo
 
Hello Flutterの次におさえたいFlutterのポイント
Kenichi Kambara
 
The Little Shop of TDD Horrors
Giorgio Natili
 
Ad

More from Codemotion (20)

PDF
Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
Codemotion
 
PDF
Pompili - From hero to_zero: The FatalNoise neverending story
Codemotion
 
PPTX
Pastore - Commodore 65 - La storia
Codemotion
 
PPTX
Pennisi - Essere Richard Altwasser
Codemotion
 
PPTX
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
Codemotion
 
PPTX
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
Codemotion
 
PPTX
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
Codemotion
 
PPTX
Francesco Baldassarri - Deliver Data at Scale - Codemotion Amsterdam 2019 -
Codemotion
 
PDF
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
Codemotion
 
PDF
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
Codemotion
 
PDF
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
Codemotion
 
PDF
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
Codemotion
 
PDF
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
Codemotion
 
PDF
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
Codemotion
 
PPTX
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
Codemotion
 
PPTX
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
Codemotion
 
PDF
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
Codemotion
 
PDF
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
Codemotion
 
PDF
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
Codemotion
 
PDF
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
Codemotion
 
Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
Codemotion
 
Pompili - From hero to_zero: The FatalNoise neverending story
Codemotion
 
Pastore - Commodore 65 - La storia
Codemotion
 
Pennisi - Essere Richard Altwasser
Codemotion
 
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
Codemotion
 
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
Codemotion
 
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
Codemotion
 
Francesco Baldassarri - Deliver Data at Scale - Codemotion Amsterdam 2019 -
Codemotion
 
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
Codemotion
 
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
Codemotion
 
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
Codemotion
 
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
Codemotion
 
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
Codemotion
 
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
Codemotion
 
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
Codemotion
 
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
Codemotion
 
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
Codemotion
 
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
Codemotion
 
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
Codemotion
 
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
Codemotion
 
Ad

Recently uploaded (20)

PDF
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
PDF
AI-Cloud-Business-Management-Platforms-The-Key-to-Efficiency-Growth.pdf
Artjoker Software Development Company
 
PDF
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PPTX
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
PPTX
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
PDF
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
PDF
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
PDF
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
PDF
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
PPTX
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
PPTX
Introduction to Flutter by Ayush Desai.pptx
ayushdesai204
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
PPTX
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
PDF
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
PDF
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
PDF
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
PDF
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
PDF
The Future of Artificial Intelligence (AI)
Mukul
 
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
AI-Cloud-Business-Management-Platforms-The-Key-to-Efficiency-Growth.pdf
Artjoker Software Development Company
 
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
Introduction to Flutter by Ayush Desai.pptx
ayushdesai204
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
The Future of Artificial Intelligence (AI)
Mukul
 

Reactive MVP - Giorgio Natili - Codemotion Rome 2017