SlideShare a Scribd company logo
Três conceitos que farão
a diferença nos seus apps
• Networking e storage
• Diffing
• Navegação entre telas
MDP
My Design Pattern
Abstração
Offline Controllers
Fui usar o app em modo avião e olha no que deu
ViewController.swift
ViewController.swift
ViewController
ViewController
View Controller
Data Provider
Storage Controller API Client
API Client
View Controller
Data Provider
Storage Controller API Client
Storage Controller
View Controller
Data Provider
Storage Controller API Client
Data Provider
View Controller
Data Provider
Storage Controller API Client
HTTPJSON
SERVIDOR
API
REALM
OBJECTS
REALM
HTTPJSON
SERVIDOR
API
REALM
OBJECTS
REALM
HTTPJSON
SERVIDOR
API
REALM
OBJECTS
REALM
SUBSCRIBE
[USERS]
HTTPJSON
SERVIDOR
API
REALM
OBJECTS
REALM
SUBSCRIBE
[USERS]
HTTPJSON
SERVIDOR
API
REALM
OBJECTS
REALM
SUBSCRIBE
[USERS]
HTTPJSON
SERVIDOR
API
REALM
OBJECTS
REALM
SUBSCRIBE
[USERS]
HTTPJSON
SERVIDOR
API
REALM
OBJECTS
REALM
SUBSCRIBE
[USERS]
HTTPJSON
SERVIDOR
API
REALM
OBJECTS
REALM
SUBSCRIBE
[USERS]
HTTPJSON
SERVIDOR
API
REALM
OBJECTS
REALM
SUBSCRIBE
[USERS]
HTTPJSON
SERVIDOR
API
REALM
OBJECTS
REALM
SUBSCRIBE
[USERS]
HTTPJSON
SERVIDOR
API
REALM
OBJECTS
REALM
SUBSCRIBE
[USERS]
HTTPJSON
SERVIDOR
API
REALM
OBJECTS
REALM
SUBSCRIBE
[USERS]
HTTPJSON
SERVIDOR
API
REALM
OBJECTS
REALM
SUBSCRIBE
[USERS]
HTTPJSON
SERVIDOR
API
REALM
OBJECTS
REALM
SUBSCRIBE
[USERS]
HTTPJSON
SERVIDOR
API
REALM
OBJECTS
REALM
SUBSCRIBE
[USERS]
HTTPJSON
SERVIDOR
API
REALM
OBJECTS
REALM
SUBSCRIBE
[USERS]
HTTPJSON
SERVIDOR
API
REALM
OBJECTS
REALM
SUBSCRIBE
[USERS]
HTTPJSON
SERVIDOR
API
REALM
OBJECTS
REALM
SUBSCRIBE
[USERS]
HTTPJSON
SERVIDOR
API
REALM
OBJECTS
REALM
SUBSCRIBE
[USERS]
final class DataProvider {
init(client: APIClient, storage: Storage) {
self.client = client
self.storage = storage
}
/// ...
}
protocol APIClient {
func searchUsers(query: String, completion: @escaping
(Result<SearchResults<User>, APIError>) -> ())
func user(with login: String, completion: @escaping (Result<User,
APIError>) -> ())
func repositories(by login: String, completion: @escaping
(Result<[Repository], APIError>) -> ())
func repository(by login: String, named name: String, completion:
@escaping (Result<Repository, APIError>) -> ())
func stargazers(for repositoryName: String, ownedBy login: String,
completion: @escaping(Result<[User], APIError>) -> ())
}
protocol Storage: class {
func store(users: [User], completion: ((StorageError?) -> ())?)
func store(repositories: [Repository], completion:
((StorageError?) -> ())?)
func searchUsers(with query: String) -> Observable<[User]>
func user(withLogin login: String) -> Observable<User>
func user(withId id: String) -> Observable<User>
func repositories(by user: User) -> Observable<[Repository]>
func repository(named name: String) -> Observable<Repository>
func repository(withId id: String) -> Observable<Repository>
func stargazers(for repository: Repository) -> Observable<[User]>
}
Diffing
Calculando diferenças entre coleções de models
struct Repository {
let id: Int
let name: String
let owner: User
let stars: Int
}
id: 1
name: repoA
owner: {insidegui}
stars: 100
id: 2
name: repoB
owner: {insidegui}
stars: 200
let repositories: [Repository]
0
1
id: 1
name: repoA
owner: {insidegui}
stars: 102
id: 2
name: repoB
owner: {insidegui}
stars: 200
let repositories: [Repository]
0
1
id: 1
name: repoA
owner: {insidegui}
stars: 102
id: 2
name: repoB
owner: {insidegui}
stars: 200
difference = [.modified(0)]
0
1
id: 1
name: repoA
owner: {insidegui}
stars: 100
id: 2
name: repoB
owner: {insidegui}
stars: 200
0
1
id: 3
name: repoC
owner: {insidegui}
stars: 300
id: 2
name: repoB
owner: {insidegui}
stars: 200
let repositories: [Repository]
0
1
id: 3
name: repoC
owner: {insidegui}
stars: 300
id: 2
name: repoB
owner: {insidegui}
stars: 200
difference = [.deleted(0), .added(0)]
0
1
id: 1
name: repoA
owner: {insidegui}
stars: 102
id: 2
name: repoB
owner: {insidegui}
stars: 200
0
1
X
Levenshtein
let diff = IGListDiffPaths(0, 0, oldData, newData, .equality)
tableView.beginUpdates()
tableView.insertRows(at: diff.inserts, with: .automatic)
tableView.deleteRows(at: diff.deletes, with: .automatic)
tableView.reloadRows(at: diff.updates, with: .none)
tableView.endUpdates()
extension UITableView {
func reload(oldData: [IGListDiffable], newData: [IGListDiffable]) {
let diff = IGListDiffPaths(0, 0, oldData, newData, .equality)
beginUpdates()
insertRows(at: diff.inserts, with: .automatic)
deleteRows(at: diff.deletes, with: .automatic)
reloadRows(at: diff.updates, with: .none)
endUpdates()
}
}
Routers
Conectando seus view controllers sem perder a sanidade
#comofas?
SEGUES
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "showRepositories" {
if let vc = segue.destination as? RepositoriesViewController {
vc.user = self.user
}
}
}
init(provider: DataProvider,
user: User,
delegate: RepositoriesViewControllerDelegate)
Dependency Injection
final class AppRouter {
init(appLaunchOptions: [UIApplicationLaunchOptionsKey : Any]?)
func showInitialViewController()
func showRepositoriesViewController(for user: User)
func showStargazersViewController(for repository: Repository)
func showProfileViewController(for user: User,
from presenting: UIViewController? = nil)
}
AppRouter.swift
class AppDelegate: UIResponder, UIApplicationDelegate {
var router: AppRouter!
func application(..., didFinishLaunching:...) -> Bool {
router = AppRouter(appLaunchOptions: launchOptions)
router.showInitialViewController()
return true
}
}
func showInitialViewController() {
if preferences.needsMigration {
showMigrationViewController(with: "Migrating, please wait")
storage.migrate(completion: showSearchViewController)
} else {
showSearchViewController()
}
}
extension AppRouter: UsersTableViewControllerDelegate {
// ...
}
extension AppRouter: RepositoriesTableViewControllerDelegate {
// ...
}
override func tableView(..., didSelectRowAt...) {
delegate?.usersTableViewController(self, didSelect: ...)
}
func usersTableViewController(_ controller: ..., didSelect user: User) {
if controller is SearchUsersViewController {
showRepositoriesViewController(for: user)
} else if controller is StargazersViewController {
showProfileViewController(for: user)
}
}
OBRIGADO!
Guilherme Rambo
github.com/insidegui
Twitter: @_inside
Github: github.com/insidegui

More Related Content

What's hot

TurboGears2 Pluggable Applications
TurboGears2 Pluggable ApplicationsTurboGears2 Pluggable Applications
TurboGears2 Pluggable Applications
Alessandro Molina
 
Hidden Treasures in Project Wonder
Hidden Treasures in Project WonderHidden Treasures in Project Wonder
Hidden Treasures in Project Wonder
WO Community
 
Web весна 2013 лекция 6
Web весна 2013 лекция 6Web весна 2013 лекция 6
Web весна 2013 лекция 6
Technopark
 
Web осень 2012 лекция 6
Web осень 2012 лекция 6Web осень 2012 лекция 6
Web осень 2012 лекция 6
Technopark
 

What's hot (20)

Python Code Camp for Professionals 3/4
Python Code Camp for Professionals 3/4Python Code Camp for Professionals 3/4
Python Code Camp for Professionals 3/4
 
Python Code Camp for Professionals 4/4
Python Code Camp for Professionals 4/4Python Code Camp for Professionals 4/4
Python Code Camp for Professionals 4/4
 
APPlause - DemoCamp Munich
APPlause - DemoCamp MunichAPPlause - DemoCamp Munich
APPlause - DemoCamp Munich
 
Using Groovy with Jenkins
Using Groovy with JenkinsUsing Groovy with Jenkins
Using Groovy with Jenkins
 
Url programming
Url programmingUrl programming
Url programming
 
Введение в REST API
Введение в REST APIВведение в REST API
Введение в REST API
 
Power shell examples_v4
Power shell examples_v4Power shell examples_v4
Power shell examples_v4
 
Rest api with Python
Rest api with PythonRest api with Python
Rest api with Python
 
Djangocon 2014 - Django REST Framework - So Easy You Can Learn it in 25 Minutes
Djangocon 2014 - Django REST Framework - So Easy You Can Learn it in 25 MinutesDjangocon 2014 - Django REST Framework - So Easy You Can Learn it in 25 Minutes
Djangocon 2014 - Django REST Framework - So Easy You Can Learn it in 25 Minutes
 
Finding Clojure
Finding ClojureFinding Clojure
Finding Clojure
 
CodeIgniter 3.0
CodeIgniter 3.0CodeIgniter 3.0
CodeIgniter 3.0
 
Phoenix + Reactで 社内システムを 密かに作ってる
Phoenix + Reactで 社内システムを 密かに作ってるPhoenix + Reactで 社内システムを 密かに作ってる
Phoenix + Reactで 社内システムを 密かに作ってる
 
Timothy N. Tsvetkov, Rails 3.1
Timothy N. Tsvetkov, Rails 3.1Timothy N. Tsvetkov, Rails 3.1
Timothy N. Tsvetkov, Rails 3.1
 
Play!ng with scala
Play!ng with scalaPlay!ng with scala
Play!ng with scala
 
TurboGears2 Pluggable Applications
TurboGears2 Pluggable ApplicationsTurboGears2 Pluggable Applications
TurboGears2 Pluggable Applications
 
Hidden Treasures in Project Wonder
Hidden Treasures in Project WonderHidden Treasures in Project Wonder
Hidden Treasures in Project Wonder
 
Web Crawling with NodeJS
Web Crawling with NodeJSWeb Crawling with NodeJS
Web Crawling with NodeJS
 
Web весна 2013 лекция 6
Web весна 2013 лекция 6Web весна 2013 лекция 6
Web весна 2013 лекция 6
 
Chef 0.10 Overview
Chef 0.10 OverviewChef 0.10 Overview
Chef 0.10 Overview
 
Web осень 2012 лекция 6
Web осень 2012 лекция 6Web осень 2012 лекция 6
Web осень 2012 лекция 6
 

Similar to Três conceitos que farão a diferença nos seus apps

Google apps script database abstraction exposed version
Google apps script database abstraction   exposed versionGoogle apps script database abstraction   exposed version
Google apps script database abstraction exposed version
Bruce McPherson
 

Similar to Três conceitos que farão a diferença nos seus apps (20)

Using VueJS in front of Drupal 8
Using VueJS in front of Drupal 8Using VueJS in front of Drupal 8
Using VueJS in front of Drupal 8
 
Server side rendering with React and Symfony
Server side rendering with React and SymfonyServer side rendering with React and Symfony
Server side rendering with React and Symfony
 
Android DevConference - Android Clean Architecture
Android DevConference - Android Clean ArchitectureAndroid DevConference - Android Clean Architecture
Android DevConference - Android Clean Architecture
 
Apache Calcite Tutorial - BOSS 21
Apache Calcite Tutorial - BOSS 21Apache Calcite Tutorial - BOSS 21
Apache Calcite Tutorial - BOSS 21
 
Devoxx 2012 hibernate envers
Devoxx 2012   hibernate enversDevoxx 2012   hibernate envers
Devoxx 2012 hibernate envers
 
Server Side Swift - AppBuilders 2017
Server Side Swift - AppBuilders 2017Server Side Swift - AppBuilders 2017
Server Side Swift - AppBuilders 2017
 
In The Trenches With Tomster, Upgrading Ember.js & Ember Data
In The Trenches With Tomster, Upgrading Ember.js & Ember DataIn The Trenches With Tomster, Upgrading Ember.js & Ember Data
In The Trenches With Tomster, Upgrading Ember.js & Ember Data
 
In The Trenches With Tomster, Upgrading Ember.js & Ember Data
In The Trenches With Tomster, Upgrading Ember.js & Ember DataIn The Trenches With Tomster, Upgrading Ember.js & Ember Data
In The Trenches With Tomster, Upgrading Ember.js & Ember Data
 
Firebase ng2 zurich
Firebase ng2 zurichFirebase ng2 zurich
Firebase ng2 zurich
 
Prairie DevCon 2015 - Crafting Evolvable API Responses
Prairie DevCon 2015 - Crafting Evolvable API ResponsesPrairie DevCon 2015 - Crafting Evolvable API Responses
Prairie DevCon 2015 - Crafting Evolvable API Responses
 
Api's and ember js
Api's and ember jsApi's and ember js
Api's and ember js
 
Free The Enterprise With Ruby & Master Your Own Domain
Free The Enterprise With Ruby & Master Your Own DomainFree The Enterprise With Ruby & Master Your Own Domain
Free The Enterprise With Ruby & Master Your Own Domain
 
ql.io at NodePDX
ql.io at NodePDXql.io at NodePDX
ql.io at NodePDX
 
Crud operations using aws dynamo db with flask ap is and boto3
Crud operations using aws dynamo db with flask ap is and boto3Crud operations using aws dynamo db with flask ap is and boto3
Crud operations using aws dynamo db with flask ap is and boto3
 
Ember.js - A JavaScript framework for creating ambitious web applications
Ember.js - A JavaScript framework for creating ambitious web applications  Ember.js - A JavaScript framework for creating ambitious web applications
Ember.js - A JavaScript framework for creating ambitious web applications
 
2016 - Serverless Microservices on AWS with API Gateway and Lambda
2016 - Serverless Microservices on AWS with API Gateway and Lambda2016 - Serverless Microservices on AWS with API Gateway and Lambda
2016 - Serverless Microservices on AWS with API Gateway and Lambda
 
-Kotlin_Camp_Unit2.pptx
-Kotlin_Camp_Unit2.pptx-Kotlin_Camp_Unit2.pptx
-Kotlin_Camp_Unit2.pptx
 
-Kotlin Camp Unit2.pptx
-Kotlin Camp Unit2.pptx-Kotlin Camp Unit2.pptx
-Kotlin Camp Unit2.pptx
 
Google apps script database abstraction exposed version
Google apps script database abstraction   exposed versionGoogle apps script database abstraction   exposed version
Google apps script database abstraction exposed version
 
Connecting your Python App to OpenERP through OOOP
Connecting your Python App to OpenERP through OOOPConnecting your Python App to OpenERP through OOOP
Connecting your Python App to OpenERP through OOOP
 

Recently uploaded

Recently uploaded (20)

IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
In-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsIn-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT Professionals
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1
 
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and Planning
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through Observability
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
 

Três conceitos que farão a diferença nos seus apps