Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up
for free
Setting Boundaries
Francisco Díaz
March 10, 2016
Programming
1
52
Setting Boundaries
Presented at ViDIA meetup.
Francisco Díaz
March 10, 2016
Tweet
Share
More Decks by Francisco Díaz
See All by Francisco Díaz
fdiaz
4
190
fdiaz
0
40
fdiaz
1
25
fdiaz
2
54
fdiaz
1
230
fdiaz
1
42
fdiaz
0
32
fdiaz
0
41
Other Decks in Programming
See All in Programming
kaz29
2
130
kodetr
0
160
naototty
1
110
kulkarniankita09
0
270
ktgrstsh
1
210
rockname
1
330
mathetake
7
2.2k
sysrich
0
250
deepu105
1
190
daipresents
0
340
o0h
PRO
0
350
dnskimo
8
1.5k
Featured
See All Featured
sstephenson
146
12k
morganepeng
21
1.3k
pauljervisheath
195
15k
reverentgeek
28
2.1k
danielanewman
202
20k
caitiem20
311
17k
erikaheidi
15
4.5k
robhawkes
53
2.9k
shpigford
370
42k
revolveconf
201
9.7k
dotmariusz
94
5.5k
qrush
285
19k
Transcript
Setting Boundaries
None
Francisco Díaz @fco_diaz
3 iOS Devs 28 hours 1 project == Merge Conflicts
What do we want? → Minimize duplication of code. →
Develop independently without stepping on each other's toes.
Feature verticals: → Big Panic button → Today widget →
Knock
Big Panic button:
What needs to be done? → Create the button. →
We need a way to create reports. → Make a backend call to save this information.
Today widget:
What needs to be done? → Create the extension button.
→ We need a way to create reports. → Make a backend call to save this information.
What was it that we wanted? → Minimize duplication of
code. → Develop independently without stepping on each other's toes.
None
Let's try again!
→ Create the button. → We need a way to
create reports. → Make a backend call to save this information.
UI / Presentation Create the button.
Business logic We need a way to create reports.
Backend connection Make a backend call to save this information.
None
To recap: → Minimize duplication of code. → Develop independently
without stepping on each other's toes.
We can solve any problem by introducing an extra level
of indirection — David Wheeler
Dependency inversion
struct ModelDataManager { let APIClient: APIType init(APIClient: APIType) { self.APIClient
= APIClient } }
protocol APIType { func createReport(completion: JSONDictionary? -> Void) } struct
API { private let manager: Alamofire.Manager init() { manager = Alamofire.Manager() } } extension API: APIType { func createReport(completion: JSONDictionary? -> Void) { manager.request(.POST, "https://some.com/api/report") .responseJSON { response in completion(response) } } }
struct ModelDataManager { let APIClient: APIType init(API: APIType) { self.APIClient
= API } static func defaultManager() -> ModelDataManager { let APIClient = API() return ModelDataManager(API: APIClient) } func createReport(completionHandler completion: Report? -> Void) { APIClient.createReport() { jsonDictionary in let report = ... // Parse jsonDictionary into Report completion(report) } } }
Benefits → Testable. → Decoupled. → Easy to fake our
networking layer.
None
struct FakeAPI: APIType { func createReport(completion: JSONDictionary? -> Void) {
let dictionary = ["id": 12345] completion(dictionary) } }
struct ModelDataManager { let APIClient: APIType init(API: APIType) { self.APIClient
= API } static func defaultManager() -> ModelDataManager { // let APIClient = API() let APIClient = FakeAPI() return ModelDataManager(API: APIClient) } }
Questions? Slides are available at: https://github.com/fdiaz/settings-boundaries-talk References: Architecture: The Lost
Years The Clean Architecture