SlideShare a Scribd company logo
1 of 81
Download to read offline
Build An App With Blindfold
Britt Barak
Droidcon TLV
26.9.16
Britt Barak
Britt Barak
@BrittBarak
● Figure 8
● Android Academy TLV
Largest Android Community
Android Academy - TLV
TLV - Android Academy
~ 1500 members Join Us:
Upcoming Events
● Android Beginners - coming on 30/10 !
● Android UI / UX
● Community Hackathon
● Android Performance
● Mentors Program
My First Startup
“As You Like It” / W. Shakespeare
‫״‬All the world’s a stage,
And all the men and women merely players;
They have their exits and their entrances,
And one man in his time plays many parts:‫״‬
His acts being seven ages. At first, the
infant,
Mewling and puking in the nurse’s arms.
Then the whining schoolboy, with his
satchel
And shining morning face, creeping like
snail
Unwillingly to school. And then the lover,
Sighing like furnace, with a woeful ballad
Made to his mistress’ eyebrow. Then a
soldier,
Full of strange oaths and bearded like the
pard,
Jealous in honor, sudden and quick in
quarrel,
Seeking the bubble reputation
Even in the cannon’s mouth. And then the
justice,
In fair round belly with good capon lined,
With eyes severe and beard of formal cut,
Full of wise saws and modern instances;
And so he plays his part. The sixth age
shifts
Into the lean and slippered pantaloon,
With spectacles on nose and pouch on side;
His youthful hose, well saved, a world too
wide
For his shrunk shank, and his big manly
voice,
Turning again toward childish treble, pipes
And whistles in his sound. Last scene of
all,
That ends this strange eventful history,
Is second childishness and mere oblivion,
Sans teeth, sans eyes, sans taste, sans
everything.
“exits and entrances”
The part can change
But there’s always a defined part.
File → New Project
New Startups
● Uncertainty
● Many changes
● Low on resources
○ Time
○ Developers
○ Money
We Want To Deliver Fast!
Premature optimizations are bad
1. Mess Grows
2. Structure Stays
Recipe
1. Big picture - who are the “players”?
2. Small use cases - what are the “parts”?
3. Choose POCs - order “exits and entrances”
High Level Structure
Presentation
Layer
Data LayerDomain Layer
High Level Structure
Presentation
Layer
● View
● ViewEntity
● Presenter
→ Framework
Data Layer
● Repository
● Entity
→ Java
Domain Layer
● Interactor
● Use case
→ Java
Example : Add Chat Feature To App
Big Picture - The Players
● Add chat feature to the app
● Chat between groups of members
Separation
App
Module
Chat
Module
Why New Module?
- Encapsulate implementation
- Easy to replace
- Easy to reuse
Structure:
Presentation Layer - App Module
Data Layer - Chat Module
let‘s talk about the data structure.
Firebase DB
- Easy.
- noSQL
- Flat
- Get data by reference
- ref/messages/chat_one_id
Don’t - Nest
{
"chats": {
"chatOneId": {
"title": "As You Like It",
"messages": {
"msg1Id": { "sender": "melancholyJaques", "message": "All world’s a stage." },
"msg2Id": { ... },
// a very long list of messages
}
},
"chatTwoId": { ... }
}
}
Do - Flat : Chats
{
"chats": {
"chatOneId": {
"title": "As You Like It"
},
"chatTwoId": { ... },
"chatThreeId": { ... }
}
Do - Flat : Members
{
"members": {
"chatOneId": {
"melancholyJaques": true,
"dukeSenior": true,
},
"chatTwoId": { ... },
"chatThreeId": { ... }
},
Do - Flat : Users
{
"users": {
"melancholyJaques": {
"name": Melancholy Jaques",
"photoId": "23h42",
"chats": {
"chatOneId": true,
"chatTwoId": true
}
},
...
},
Do - Flat : Messages
"messages": {
"chatOneId": {
"msg1Id": {
"sender": "melancholyJaques",
"message": "All world’s a stage.",
"timestamp": 1459361875337
},
"msg2Id": { ... },
// a very long list of messages
},
"chatTwoId": { ... },
}
}
On my code
Chat module: individual separate pieces:
- Chats Repository
- Members Repository
- Users Repository
- Messages Repository
Repository (Data Layer)
Part - provide and update data.
Encapsulates implementation.
public class UsersRepo implements IUsersRepository {
MyFirebaseDBClient firebaseClient;
@Override
public void getChatIDs(Callback callback) {
firebaseClient.fetchChats(callback);
}
public class UsersRepo implements IUsersRepository {
MyFirebaseDBClient firebaseClient;
MyCache cache;
@Override
public void getChatIDs(Callback callback) {
if (cache.hasChats()) {
callback.success(cache.getChatIDs());
} else {
firebaseClient.fetchChatIDs(callback);
}
}
public class UsersRepo implements IUsersRepository {
MyFirebaseDBClient firebaseClient;
MyCache cache;
ChatsLocalDB localDB;
@Override
public void getChatIDs(Callback callback) {
if (cache.hasChatIDs()) {
callback.success(cache.getChatIDs());
} else if (localDB.hasChatIDs()) {
callback.success(localDB.getChatIDs());
} else {
firebaseClient.fetchChatIDs(callback);
}
}
public class UsersRepo implements IUsersRepository {
MyApiClient apiClient;
MyCache cache;
ChatsLocalDB localDB;
@Override
public void getChatIDs(Callback callback) {
if (cache.hasChatIDs()) {
callback.success(cache.getChatIDs());
} else if (localDB.hasChatIDs()) {
callback.success(localDB.getChatIDs());
} else {
apiClient.fetchChatIDs(callback);
}
}
Recipe
1. Big picture - who are the “players”?
2. Small use cases - what are the “parts”?
3. Choose POCs - order “exits and entrances”
Domain layer - Use Cases
Use cases / interactors
What does the app do? What are its use cases?
Example: getChatsPreviewList (use case)
Get
user’s
chat IDs
Get
chat’s
info
Chats
Repo
Get
chats
preview
list
Chat
list
activity
Users
Repo
Get Chat Preview List
Get chats
preview
list
List<Chat>
List<String>
ChatRaw
Get Chat Preview List
List<ChatRaw>
Get Chat Preview List
public class GetChatPreviewListImpl implements GetChatsPreviewList {
public void execute(final Callback<List<Chat>> callback) {
usersRepo.getChatIDs(new Callback<List<String>>() {
@Override
public void success(List<String> chatIDs) {
chatsRepo.getChats(new Callback<List<RawChat>>() {
@Override
public void success(List<RawChat> rawChats) {
List<Chat> chats = proccessChats(rawChats);
callback.success(chats);
}
});
}
});
Get chats
preview
list
Get chat
members
Get chat
messags
….
App Module Will Ask For More
Chat
list
activity
Recipe
1. Big picture - who are the “players”?
2. Small use cases - what are the “parts”?
3. Choose POCs - order “exits and entrances”
Choose POC
- Play the App Module Part:
- Forget the chat implementation!
- ChatClient - POC class
Chat Client
Get chats
preview
list
Get chat
members
Get chat
messags
….
Choose POC
App
Module
Get Chat Preview List
Chat
list
activity
Chat
Client
Users
Repo
Chats
Repo
userId chatIds
Demand
On chats preview list:
show last message
Get Chat Preview List 2
Too messy. Too many listeners and threads. Too much time.
Chat
Client
Users
Repo
Chat
list
activity
Chats
Repo
userId chatIds
Msgs
Repo
Get
chats
preview
list
Get Chat Preview List 3
Add data straight to chat Info node
"chats": {
"chatOneId": {
"title": "As You Like It"
"lastMessage": "All world’s a stage"
},
"chatTwoId": { ... },
"chatThreeId": { ... }
},
Get Chat Preview List 3
Too messy. Too many listeners and threads. Too much time.
Chat
Client
Users
Repo
Chat
list
activity
Chats
Repo
userId chatIdsGet
chats
preview
list
But now:
more work when sending a message
Send : Before
Chat
activity
Chat
Client
Msgs
Repo
Send
Send : After
Chat
activity
Chat
Client
Msgs
Repo
Send
Chats
Repo
Demand
Message visibility per user.
“Last message”
isn’t general anymore.
Structure - Message
"message1": {
...
"visibleTo": {
"userId1": true,
"userId2": true
},
}
Structure - Personal Chat Info
Chats
General
Info
Personal
Info
title
Last
msg
Personal Chat Info Node
{
"personalInfo": {
"melancholyJaques": {
"lastMessage": All world’s a stage",
"timestamp": 1459361875337
},
...
},
Get Chat Preview List 4
Too messy. Too many listeners and threads. Too much time.
Chat
Client
Users
Repo
Chat
list
activity
userId chatIdsGet
chats
preview
list
personal
Info
Repo
general
Info
Repo
Send : Update Per User
App
Module
Chat
Client
Msgs
Repo
userId chatIds
personal
Info
Repo
Send
Is visible?
But I have many recipients….
Takes long to update each user repo...
Send :
Send
Message
Repo
FCM
Receive :
Send Receive
Personal
Info
Repo
Message
Repo
FCM
Give the part to a differenet Player
Sum Up
- Small defined use cases:
- Easy to maintain
- Easy to change
- Easy to test
- Mix and match
- “Play the part” → create POC class
- Encapsulate implementation
- Organize code
- Be mindful to what needs a change
Example changing the part
FCM Usages
- Notify user
- Update DB
- Update UI
- Fetch new data
- Start service
- ……...
How Does It Work?
public class MyFCMService extends FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
//...
}
}
Remote Message Part
Notify about an event.
FCM Handling
Type per message
RemoteMessage
Data
….
< “type” , “new_chat_message” >
….
FCM Handling
public class MyFCMService extends FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
String type = data.get(StaticKeys.KEY_TYPE);
switch (type) {
//....
}
}
}
It Worked Great...
We added up more and more events…..
- New chat message
- New member added
- Member removed
- New data available
- ………………..
…for some time :-/
- Too many event types
- Too complex code
- Hard to change
- Hard to combine
- Sometimes one usecase represented multiple event types and forced few fcm
messages
- The ugly switch-case...
Demand
- Easily support new types
- Change remotely
Wait….
Take a step back.
What did we mean to do?
1. Notifying users
2. Update data / ui
3. Update DB
Remote Message Part
Notify an event.
Notify about stuff that need to be done.
Handle By Data Attributes
RemoteMessage
Data
….
<“notify” , “true” >
<“title” , “New Message” >
<“icon” , “ic_chat” >
<“click_action”,
“com.figure8.app.action.OPEN_CHAT”>
<“refresh_members”, chat_id>
….
Handle By Data Attributes
Messaging
Service
Notif
Producer
Data
Refresher
DB
Updater
Remote
Message
Remote
Message
Pros
- Flexible
- Update remotely
- Test:
- Test the data producer
- Test the data handler
What Did We Do?
Gave the component a different part.
“exits and entrances”
The part can change
But there’s always a defined part.
Questions?
Thank you :)

More Related Content

What's hot

Servlet sessions
Servlet sessionsServlet sessions
Servlet sessions
vantinhkhuc
 
10 performance and scalability secrets of ASP.NET websites
10 performance and scalability secrets of ASP.NET websites10 performance and scalability secrets of ASP.NET websites
10 performance and scalability secrets of ASP.NET websites
oazabir
 

What's hot (20)

Servlet sessions
Servlet sessionsServlet sessions
Servlet sessions
 
10 performance and scalability secrets of ASP.NET websites
10 performance and scalability secrets of ASP.NET websites10 performance and scalability secrets of ASP.NET websites
10 performance and scalability secrets of ASP.NET websites
 
AAI 2236-Using the New Java Concurrency Utilities with IBM WebSphere
AAI 2236-Using the New Java Concurrency Utilities with IBM WebSphereAAI 2236-Using the New Java Concurrency Utilities with IBM WebSphere
AAI 2236-Using the New Java Concurrency Utilities with IBM WebSphere
 
Scaling asp.net websites to millions of users
Scaling asp.net websites to millions of usersScaling asp.net websites to millions of users
Scaling asp.net websites to millions of users
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
Ajax
AjaxAjax
Ajax
 
Scaling with Scala: refactoring a back-end service into the mobile age
Scaling with Scala: refactoring a back-end service into the mobile ageScaling with Scala: refactoring a back-end service into the mobile age
Scaling with Scala: refactoring a back-end service into the mobile age
 
Spring 4 Web App
Spring 4 Web AppSpring 4 Web App
Spring 4 Web App
 
Jquery Ajax
Jquery AjaxJquery Ajax
Jquery Ajax
 
Zotonic tutorial EUC 2013
Zotonic tutorial EUC 2013Zotonic tutorial EUC 2013
Zotonic tutorial EUC 2013
 
Servlet
ServletServlet
Servlet
 
AJAX
AJAXAJAX
AJAX
 
Developing on SQL Azure
Developing on SQL AzureDeveloping on SQL Azure
Developing on SQL Azure
 
Enterprise java unit-2_chapter-2
Enterprise  java unit-2_chapter-2Enterprise  java unit-2_chapter-2
Enterprise java unit-2_chapter-2
 
Akka lsug skills matter
Akka lsug skills matterAkka lsug skills matter
Akka lsug skills matter
 
Ajax ppt - 32 slides
Ajax ppt - 32 slidesAjax ppt - 32 slides
Ajax ppt - 32 slides
 
Making it fast: Zotonic & Performance
Making it fast: Zotonic & PerformanceMaking it fast: Zotonic & Performance
Making it fast: Zotonic & Performance
 
Servlets & jdbc
Servlets & jdbcServlets & jdbc
Servlets & jdbc
 
Ajax
AjaxAjax
Ajax
 
SenchaCon 2016: Learn the Top 10 Best ES2015 Features - Lee Boonstra
SenchaCon 2016: Learn the Top 10 Best ES2015 Features - Lee Boonstra  SenchaCon 2016: Learn the Top 10 Best ES2015 Features - Lee Boonstra
SenchaCon 2016: Learn the Top 10 Best ES2015 Features - Lee Boonstra
 

Viewers also liked

What Should You Expect from Education by Entertainment Programs?
What Should You Expect from Education by Entertainment Programs?What Should You Expect from Education by Entertainment Programs?
What Should You Expect from Education by Entertainment Programs?
Ronald G. Shapiro
 
Diarmuid GAMIFY YOUR LIFE
Diarmuid GAMIFY YOUR LIFEDiarmuid GAMIFY YOUR LIFE
Diarmuid GAMIFY YOUR LIFE
Diarmundo
 

Viewers also liked (20)

Blindfold
BlindfoldBlindfold
Blindfold
 
Becky and Vicki's Sensewalk
Becky and Vicki's SensewalkBecky and Vicki's Sensewalk
Becky and Vicki's Sensewalk
 
What Should You Expect from Education by Entertainment Programs?
What Should You Expect from Education by Entertainment Programs?What Should You Expect from Education by Entertainment Programs?
What Should You Expect from Education by Entertainment Programs?
 
Diarmuid GAMIFY YOUR LIFE
Diarmuid GAMIFY YOUR LIFEDiarmuid GAMIFY YOUR LIFE
Diarmuid GAMIFY YOUR LIFE
 
Fun day
Fun dayFun day
Fun day
 
Prop list
Prop listProp list
Prop list
 
Creating killer apps powered by watson cognitive services - Ronen Siman-Tov, IBM
Creating killer apps powered by watson cognitive services - Ronen Siman-Tov, IBMCreating killer apps powered by watson cognitive services - Ronen Siman-Tov, IBM
Creating killer apps powered by watson cognitive services - Ronen Siman-Tov, IBM
 
Intro to Dependency Injection - Or bar
Intro to Dependency Injection - Or bar Intro to Dependency Injection - Or bar
Intro to Dependency Injection - Or bar
 
Android is going to Go! - Android and goland - Almog Baku
Android is going to Go! - Android and goland - Almog BakuAndroid is going to Go! - Android and goland - Almog Baku
Android is going to Go! - Android and goland - Almog Baku
 
Android Application Optimization: Overview and Tools - Oref Barad, AVG
Android Application Optimization: Overview and Tools - Oref Barad, AVGAndroid Application Optimization: Overview and Tools - Oref Barad, AVG
Android Application Optimization: Overview and Tools - Oref Barad, AVG
 
Write code that writes code! A beginner's guide to Annotation Processing - Ja...
Write code that writes code! A beginner's guide to Annotation Processing - Ja...Write code that writes code! A beginner's guide to Annotation Processing - Ja...
Write code that writes code! A beginner's guide to Annotation Processing - Ja...
 
Cognitive interaction using Wearables - Eyal herman, IBM
Cognitive interaction using Wearables - Eyal herman, IBMCognitive interaction using Wearables - Eyal herman, IBM
Cognitive interaction using Wearables - Eyal herman, IBM
 
3 things every Android developer must know about Microsoft - Ido Volff, Micro...
3 things every Android developer must know about Microsoft - Ido Volff, Micro...3 things every Android developer must know about Microsoft - Ido Volff, Micro...
3 things every Android developer must know about Microsoft - Ido Volff, Micro...
 
Good Rules for Bad Apps - Shem magnezi
Good Rules for Bad Apps - Shem magnezi Good Rules for Bad Apps - Shem magnezi
Good Rules for Bad Apps - Shem magnezi
 
Mobile SDKs: Use with Caution - Ori Lentzitzky
Mobile SDKs: Use with Caution - Ori LentzitzkyMobile SDKs: Use with Caution - Ori Lentzitzky
Mobile SDKs: Use with Caution - Ori Lentzitzky
 
Will it run or will it not run? Background processes in Android 6 - Anna Lifs...
Will it run or will it not run? Background processes in Android 6 - Anna Lifs...Will it run or will it not run? Background processes in Android 6 - Anna Lifs...
Will it run or will it not run? Background processes in Android 6 - Anna Lifs...
 
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
 
Context is Everything - Royi Benyossef
Context is Everything - Royi Benyossef Context is Everything - Royi Benyossef
Context is Everything - Royi Benyossef
 
Knock knock! Who's there? Doze. - Yonatan Levin
Knock knock! Who's there? Doze. - Yonatan Levin Knock knock! Who's there? Doze. - Yonatan Levin
Knock knock! Who's there? Doze. - Yonatan Levin
 
Set it and forget it: Let the machine learn its job - Guy Baron, Vonage
Set it and forget it: Let the machine learn its job - Guy Baron, VonageSet it and forget it: Let the machine learn its job - Guy Baron, Vonage
Set it and forget it: Let the machine learn its job - Guy Baron, Vonage
 

Similar to Build an App with Blindfold - Britt Barak

Using RAG to create your own Podcast conversations.pdf
Using RAG to create your own Podcast conversations.pdfUsing RAG to create your own Podcast conversations.pdf
Using RAG to create your own Podcast conversations.pdf
Richard Rodger
 
Next Gen Data Modeling in the Open Data Platform With Doron Porat and Liran Y...
Next Gen Data Modeling in the Open Data Platform With Doron Porat and Liran Y...Next Gen Data Modeling in the Open Data Platform With Doron Porat and Liran Y...
Next Gen Data Modeling in the Open Data Platform With Doron Porat and Liran Y...
HostedbyConfluent
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
Mohammad Qureshi
 
Computernetworkingkurosech9 091011003335-phpapp01
Computernetworkingkurosech9 091011003335-phpapp01Computernetworkingkurosech9 091011003335-phpapp01
Computernetworkingkurosech9 091011003335-phpapp01
AislanSoares
 
Java Technology
Java TechnologyJava Technology
Java Technology
ifnu bima
 

Similar to Build an App with Blindfold - Britt Barak (20)

Being HAPI! Reverse Proxying on Purpose
Being HAPI! Reverse Proxying on PurposeBeing HAPI! Reverse Proxying on Purpose
Being HAPI! Reverse Proxying on Purpose
 
Using RAG to create your own Podcast conversations.pdf
Using RAG to create your own Podcast conversations.pdfUsing RAG to create your own Podcast conversations.pdf
Using RAG to create your own Podcast conversations.pdf
 
Original slides from Ryan Dahl's NodeJs intro talk
Original slides from Ryan Dahl's NodeJs intro talkOriginal slides from Ryan Dahl's NodeJs intro talk
Original slides from Ryan Dahl's NodeJs intro talk
 
Spring in the Cloud - using Spring with Cloud Foundry
Spring in the Cloud - using Spring with Cloud FoundrySpring in the Cloud - using Spring with Cloud Foundry
Spring in the Cloud - using Spring with Cloud Foundry
 
Next Gen Data Modeling in the Open Data Platform With Doron Porat and Liran Y...
Next Gen Data Modeling in the Open Data Platform With Doron Porat and Liran Y...Next Gen Data Modeling in the Open Data Platform With Doron Porat and Liran Y...
Next Gen Data Modeling in the Open Data Platform With Doron Porat and Liran Y...
 
From Ruby to Node.js
From Ruby to Node.jsFrom Ruby to Node.js
From Ruby to Node.js
 
AFUP Lorraine - Symfony Webpack Encore
AFUP Lorraine - Symfony Webpack EncoreAFUP Lorraine - Symfony Webpack Encore
AFUP Lorraine - Symfony Webpack Encore
 
Our Data Ourselves, Pydata 2015
Our Data Ourselves, Pydata 2015Our Data Ourselves, Pydata 2015
Our Data Ourselves, Pydata 2015
 
MongoDB World 2018: Tutorial - Free the DBA: Building Chat Bots to Triage, Mo...
MongoDB World 2018: Tutorial - Free the DBA: Building Chat Bots to Triage, Mo...MongoDB World 2018: Tutorial - Free the DBA: Building Chat Bots to Triage, Mo...
MongoDB World 2018: Tutorial - Free the DBA: Building Chat Bots to Triage, Mo...
 
Use Web Skills To Build Mobile Apps
Use Web Skills To Build Mobile AppsUse Web Skills To Build Mobile Apps
Use Web Skills To Build Mobile Apps
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
 
Generating Unified APIs with Protocol Buffers and gRPC
Generating Unified APIs with Protocol Buffers and gRPCGenerating Unified APIs with Protocol Buffers and gRPC
Generating Unified APIs with Protocol Buffers and gRPC
 
Fully Automate Application Delivery with Puppet and F5 - PuppetConf 2014
Fully Automate Application Delivery with Puppet and F5 - PuppetConf 2014Fully Automate Application Delivery with Puppet and F5 - PuppetConf 2014
Fully Automate Application Delivery with Puppet and F5 - PuppetConf 2014
 
BreizhCamp 2013 - Pimp my backend
BreizhCamp 2013 - Pimp my backendBreizhCamp 2013 - Pimp my backend
BreizhCamp 2013 - Pimp my backend
 
Sinatra and JSONQuery Web Service
Sinatra and JSONQuery Web ServiceSinatra and JSONQuery Web Service
Sinatra and JSONQuery Web Service
 
Microservices Practitioner Summit Jan '15 - Don't Build a Distributed Monolit...
Microservices Practitioner Summit Jan '15 - Don't Build a Distributed Monolit...Microservices Practitioner Summit Jan '15 - Don't Build a Distributed Monolit...
Microservices Practitioner Summit Jan '15 - Don't Build a Distributed Monolit...
 
Computernetworkingkurosech9 091011003335-phpapp01
Computernetworkingkurosech9 091011003335-phpapp01Computernetworkingkurosech9 091011003335-phpapp01
Computernetworkingkurosech9 091011003335-phpapp01
 
Intro To Node.js
Intro To Node.jsIntro To Node.js
Intro To Node.js
 
IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ ...
IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ ...IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ ...
IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ ...
 
Java Technology
Java TechnologyJava Technology
Java Technology
 

More from DroidConTLV

More from DroidConTLV (20)

Mobile Development in the Information Age - Yossi Elkrief, Nike
Mobile Development in the Information Age - Yossi Elkrief, NikeMobile Development in the Information Age - Yossi Elkrief, Nike
Mobile Development in the Information Age - Yossi Elkrief, Nike
 
Doing work in the background - Darryn Campbell, Zebra Technologies
Doing work in the background - Darryn Campbell, Zebra TechnologiesDoing work in the background - Darryn Campbell, Zebra Technologies
Doing work in the background - Darryn Campbell, Zebra Technologies
 
No more video loss - Alex Rivkin, Motorola Solutions
No more video loss - Alex Rivkin, Motorola SolutionsNo more video loss - Alex Rivkin, Motorola Solutions
No more video loss - Alex Rivkin, Motorola Solutions
 
Mobile at Scale: from startup to a big company - Dor Samet, Booking.com
Mobile at Scale: from startup to a big company - Dor Samet, Booking.comMobile at Scale: from startup to a big company - Dor Samet, Booking.com
Mobile at Scale: from startup to a big company - Dor Samet, Booking.com
 
LiveData on Steroids - Giora Shevach + Shahar Ben Moshe, Climacell
LiveData on Steroids - Giora Shevach + Shahar Ben Moshe, ClimacellLiveData on Steroids - Giora Shevach + Shahar Ben Moshe, Climacell
LiveData on Steroids - Giora Shevach + Shahar Ben Moshe, Climacell
 
MVVM In real life - Lea Cohen Tannoudji, Lightricks
MVVM In real life - Lea Cohen Tannoudji, LightricksMVVM In real life - Lea Cohen Tannoudji, Lightricks
MVVM In real life - Lea Cohen Tannoudji, Lightricks
 
Best Practices for Using Mobile SDKs - Lilach Wagner, SafeDK (AppLovin)
Best Practices for Using Mobile SDKs - Lilach Wagner, SafeDK (AppLovin)Best Practices for Using Mobile SDKs - Lilach Wagner, SafeDK (AppLovin)
Best Practices for Using Mobile SDKs - Lilach Wagner, SafeDK (AppLovin)
 
Building Apps with Flutter - Hillel Coren, Invoice Ninja
Building Apps with Flutter - Hillel Coren, Invoice NinjaBuilding Apps with Flutter - Hillel Coren, Invoice Ninja
Building Apps with Flutter - Hillel Coren, Invoice Ninja
 
New Android Project: The Most Important Decisions - Vasiliy Zukanov
New Android Project: The Most Important Decisions - Vasiliy ZukanovNew Android Project: The Most Important Decisions - Vasiliy Zukanov
New Android Project: The Most Important Decisions - Vasiliy Zukanov
 
Designing a Design System - Shai Mishali, Gett
Designing a Design System - Shai Mishali, GettDesigning a Design System - Shai Mishali, Gett
Designing a Design System - Shai Mishali, Gett
 
The Mighty Power of the Accessibility Service - Guy Griv, Pepper
The Mighty Power of the Accessibility Service - Guy Griv, PepperThe Mighty Power of the Accessibility Service - Guy Griv, Pepper
The Mighty Power of the Accessibility Service - Guy Griv, Pepper
 
Kotlin Multiplatform in Action - Alexandr Pogrebnyak - IceRockDev
Kotlin Multiplatform in Action - Alexandr Pogrebnyak - IceRockDevKotlin Multiplatform in Action - Alexandr Pogrebnyak - IceRockDev
Kotlin Multiplatform in Action - Alexandr Pogrebnyak - IceRockDev
 
Flutter State Management - Moti Bartov, Tikal
Flutter State Management - Moti Bartov, TikalFlutter State Management - Moti Bartov, Tikal
Flutter State Management - Moti Bartov, Tikal
 
Reactive UI in android - Gil Goldzweig Goldbaum, 10bis
Reactive UI in android - Gil Goldzweig Goldbaum, 10bisReactive UI in android - Gil Goldzweig Goldbaum, 10bis
Reactive UI in android - Gil Goldzweig Goldbaum, 10bis
 
Fun with flutter animations - Divyanshu Bhargava, GoHighLevel
Fun with flutter animations - Divyanshu Bhargava, GoHighLevelFun with flutter animations - Divyanshu Bhargava, GoHighLevel
Fun with flutter animations - Divyanshu Bhargava, GoHighLevel
 
DroidconTLV 2019
DroidconTLV 2019DroidconTLV 2019
DroidconTLV 2019
 
Ok google, it's time to bot! - Hadar Franco, Albert + Stav Levi, Monday
Ok google, it's time to bot! - Hadar Franco, Albert + Stav Levi, MondayOk google, it's time to bot! - Hadar Franco, Albert + Stav Levi, Monday
Ok google, it's time to bot! - Hadar Franco, Albert + Stav Levi, Monday
 
Introduction to React Native - Lev Vidrak, Wix
Introduction to React Native - Lev Vidrak, WixIntroduction to React Native - Lev Vidrak, Wix
Introduction to React Native - Lev Vidrak, Wix
 
Bang-Bang, you have been hacked - Yonatan Levin, KolGene
Bang-Bang, you have been hacked - Yonatan Levin, KolGeneBang-Bang, you have been hacked - Yonatan Levin, KolGene
Bang-Bang, you have been hacked - Yonatan Levin, KolGene
 
Educating your app – adding ML edge to your apps - Maoz Tamir
Educating your app – adding ML edge to your apps - Maoz TamirEducating your app – adding ML edge to your apps - Maoz Tamir
Educating your app – adding ML edge to your apps - Maoz Tamir
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Recently uploaded (20)

Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 

Build an App with Blindfold - Britt Barak

  • 1. Build An App With Blindfold Britt Barak Droidcon TLV 26.9.16
  • 2. Britt Barak Britt Barak @BrittBarak ● Figure 8 ● Android Academy TLV
  • 3. Largest Android Community Android Academy - TLV TLV - Android Academy ~ 1500 members Join Us:
  • 4. Upcoming Events ● Android Beginners - coming on 30/10 ! ● Android UI / UX ● Community Hackathon ● Android Performance ● Mentors Program
  • 6. “As You Like It” / W. Shakespeare ‫״‬All the world’s a stage, And all the men and women merely players; They have their exits and their entrances, And one man in his time plays many parts:‫״‬
  • 7. His acts being seven ages. At first, the infant, Mewling and puking in the nurse’s arms. Then the whining schoolboy, with his satchel And shining morning face, creeping like snail Unwillingly to school. And then the lover, Sighing like furnace, with a woeful ballad Made to his mistress’ eyebrow. Then a soldier, Full of strange oaths and bearded like the pard, Jealous in honor, sudden and quick in quarrel, Seeking the bubble reputation Even in the cannon’s mouth. And then the justice, In fair round belly with good capon lined, With eyes severe and beard of formal cut, Full of wise saws and modern instances; And so he plays his part. The sixth age shifts Into the lean and slippered pantaloon, With spectacles on nose and pouch on side; His youthful hose, well saved, a world too wide For his shrunk shank, and his big manly voice, Turning again toward childish treble, pipes And whistles in his sound. Last scene of all, That ends this strange eventful history, Is second childishness and mere oblivion, Sans teeth, sans eyes, sans taste, sans everything.
  • 8. “exits and entrances” The part can change But there’s always a defined part.
  • 9. File → New Project
  • 10. New Startups ● Uncertainty ● Many changes ● Low on resources ○ Time ○ Developers ○ Money
  • 11. We Want To Deliver Fast! Premature optimizations are bad 1. Mess Grows 2. Structure Stays
  • 12. Recipe 1. Big picture - who are the “players”? 2. Small use cases - what are the “parts”? 3. Choose POCs - order “exits and entrances”
  • 14. High Level Structure Presentation Layer ● View ● ViewEntity ● Presenter → Framework Data Layer ● Repository ● Entity → Java Domain Layer ● Interactor ● Use case → Java
  • 15. Example : Add Chat Feature To App
  • 16. Big Picture - The Players ● Add chat feature to the app ● Chat between groups of members
  • 18. Why New Module? - Encapsulate implementation - Easy to replace - Easy to reuse
  • 20. Presentation Layer - App Module
  • 21. Data Layer - Chat Module let‘s talk about the data structure.
  • 22. Firebase DB - Easy. - noSQL - Flat - Get data by reference - ref/messages/chat_one_id
  • 23. Don’t - Nest { "chats": { "chatOneId": { "title": "As You Like It", "messages": { "msg1Id": { "sender": "melancholyJaques", "message": "All world’s a stage." }, "msg2Id": { ... }, // a very long list of messages } }, "chatTwoId": { ... } } }
  • 24. Do - Flat : Chats { "chats": { "chatOneId": { "title": "As You Like It" }, "chatTwoId": { ... }, "chatThreeId": { ... } }
  • 25. Do - Flat : Members { "members": { "chatOneId": { "melancholyJaques": true, "dukeSenior": true, }, "chatTwoId": { ... }, "chatThreeId": { ... } },
  • 26. Do - Flat : Users { "users": { "melancholyJaques": { "name": Melancholy Jaques", "photoId": "23h42", "chats": { "chatOneId": true, "chatTwoId": true } }, ... },
  • 27. Do - Flat : Messages "messages": { "chatOneId": { "msg1Id": { "sender": "melancholyJaques", "message": "All world’s a stage.", "timestamp": 1459361875337 }, "msg2Id": { ... }, // a very long list of messages }, "chatTwoId": { ... }, } }
  • 28. On my code Chat module: individual separate pieces: - Chats Repository - Members Repository - Users Repository - Messages Repository
  • 29. Repository (Data Layer) Part - provide and update data. Encapsulates implementation.
  • 30. public class UsersRepo implements IUsersRepository { MyFirebaseDBClient firebaseClient; @Override public void getChatIDs(Callback callback) { firebaseClient.fetchChats(callback); }
  • 31. public class UsersRepo implements IUsersRepository { MyFirebaseDBClient firebaseClient; MyCache cache; @Override public void getChatIDs(Callback callback) { if (cache.hasChats()) { callback.success(cache.getChatIDs()); } else { firebaseClient.fetchChatIDs(callback); } }
  • 32. public class UsersRepo implements IUsersRepository { MyFirebaseDBClient firebaseClient; MyCache cache; ChatsLocalDB localDB; @Override public void getChatIDs(Callback callback) { if (cache.hasChatIDs()) { callback.success(cache.getChatIDs()); } else if (localDB.hasChatIDs()) { callback.success(localDB.getChatIDs()); } else { firebaseClient.fetchChatIDs(callback); } }
  • 33. public class UsersRepo implements IUsersRepository { MyApiClient apiClient; MyCache cache; ChatsLocalDB localDB; @Override public void getChatIDs(Callback callback) { if (cache.hasChatIDs()) { callback.success(cache.getChatIDs()); } else if (localDB.hasChatIDs()) { callback.success(localDB.getChatIDs()); } else { apiClient.fetchChatIDs(callback); } }
  • 34. Recipe 1. Big picture - who are the “players”? 2. Small use cases - what are the “parts”? 3. Choose POCs - order “exits and entrances”
  • 35. Domain layer - Use Cases Use cases / interactors What does the app do? What are its use cases?
  • 39. Get Chat Preview List public class GetChatPreviewListImpl implements GetChatsPreviewList { public void execute(final Callback<List<Chat>> callback) { usersRepo.getChatIDs(new Callback<List<String>>() { @Override public void success(List<String> chatIDs) { chatsRepo.getChats(new Callback<List<RawChat>>() { @Override public void success(List<RawChat> rawChats) { List<Chat> chats = proccessChats(rawChats); callback.success(chats); } }); } });
  • 40. Get chats preview list Get chat members Get chat messags …. App Module Will Ask For More Chat list activity
  • 41. Recipe 1. Big picture - who are the “players”? 2. Small use cases - what are the “parts”? 3. Choose POCs - order “exits and entrances”
  • 42. Choose POC - Play the App Module Part: - Forget the chat implementation! - ChatClient - POC class
  • 43. Chat Client Get chats preview list Get chat members Get chat messags …. Choose POC App Module
  • 44. Get Chat Preview List Chat list activity Chat Client Users Repo Chats Repo userId chatIds
  • 45. Demand On chats preview list: show last message
  • 46. Get Chat Preview List 2 Too messy. Too many listeners and threads. Too much time. Chat Client Users Repo Chat list activity Chats Repo userId chatIds Msgs Repo Get chats preview list
  • 47. Get Chat Preview List 3 Add data straight to chat Info node "chats": { "chatOneId": { "title": "As You Like It" "lastMessage": "All world’s a stage" }, "chatTwoId": { ... }, "chatThreeId": { ... } },
  • 48. Get Chat Preview List 3 Too messy. Too many listeners and threads. Too much time. Chat Client Users Repo Chat list activity Chats Repo userId chatIdsGet chats preview list
  • 49. But now: more work when sending a message
  • 52. Demand Message visibility per user. “Last message” isn’t general anymore.
  • 53. Structure - Message "message1": { ... "visibleTo": { "userId1": true, "userId2": true }, }
  • 54. Structure - Personal Chat Info Chats General Info Personal Info title Last msg
  • 55. Personal Chat Info Node { "personalInfo": { "melancholyJaques": { "lastMessage": All world’s a stage", "timestamp": 1459361875337 }, ... },
  • 56. Get Chat Preview List 4 Too messy. Too many listeners and threads. Too much time. Chat Client Users Repo Chat list activity userId chatIdsGet chats preview list personal Info Repo general Info Repo
  • 57. Send : Update Per User App Module Chat Client Msgs Repo userId chatIds personal Info Repo Send Is visible?
  • 58. But I have many recipients…. Takes long to update each user repo...
  • 61. Give the part to a differenet Player
  • 62. Sum Up - Small defined use cases: - Easy to maintain - Easy to change - Easy to test - Mix and match - “Play the part” → create POC class - Encapsulate implementation - Organize code - Be mindful to what needs a change
  • 64.
  • 65. FCM Usages - Notify user - Update DB - Update UI - Fetch new data - Start service - ……...
  • 66. How Does It Work? public class MyFCMService extends FirebaseMessagingService { @Override public void onMessageReceived(RemoteMessage remoteMessage) { //... } }
  • 67. Remote Message Part Notify about an event.
  • 68. FCM Handling Type per message RemoteMessage Data …. < “type” , “new_chat_message” > ….
  • 69. FCM Handling public class MyFCMService extends FirebaseMessagingService { @Override public void onMessageReceived(RemoteMessage remoteMessage) { String type = data.get(StaticKeys.KEY_TYPE); switch (type) { //.... } } }
  • 70. It Worked Great... We added up more and more events….. - New chat message - New member added - Member removed - New data available - ………………..
  • 71. …for some time :-/ - Too many event types - Too complex code - Hard to change - Hard to combine - Sometimes one usecase represented multiple event types and forced few fcm messages - The ugly switch-case...
  • 72. Demand - Easily support new types - Change remotely
  • 73. Wait…. Take a step back. What did we mean to do? 1. Notifying users 2. Update data / ui 3. Update DB
  • 74. Remote Message Part Notify an event. Notify about stuff that need to be done.
  • 75. Handle By Data Attributes RemoteMessage Data …. <“notify” , “true” > <“title” , “New Message” > <“icon” , “ic_chat” > <“click_action”, “com.figure8.app.action.OPEN_CHAT”> <“refresh_members”, chat_id> ….
  • 76. Handle By Data Attributes Messaging Service Notif Producer Data Refresher DB Updater Remote Message Remote Message
  • 77. Pros - Flexible - Update remotely - Test: - Test the data producer - Test the data handler
  • 78. What Did We Do? Gave the component a different part.
  • 79. “exits and entrances” The part can change But there’s always a defined part.