Slide 1

Slide 1 text

New Life for Your Product @marslin_dev

Slide 2

Slide 2 text

Self-Introduction Cheng-Lung Lin A front-end team leader and an iOS developer • Twitter: @marslin_dev

Slide 3

Slide 3 text

Self-Introduction Cheng-Lung Lin A front-end team leader and an iOS developer • Twitter: @marslin_dev

Slide 4

Slide 4 text

Agenda

Slide 5

Slide 5 text

• Annoying hybrid codebase • The best architecture • Apply to product

Slide 6

Slide 6 text

Annoying Hybrid Codebase

Slide 7

Slide 7 text

New Programming Language

Slide 8

Slide 8 text

Copyright © 2000-2019 JetBrains s.r.o.

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

Powerful Swift • Generics • Enumeration with associated values • Structures / tuples • Typealiases • Nested types • so on

Slide 11

Slide 11 text

Objective-C into Swift

Slide 12

Slide 12 text

Swift into Objective-C

Slide 13

Slide 13 text

Weak Swift • Enumeration with associated values • Structures / tuples • Typealiases • Nested types • so on

Slide 14

Slide 14 text

Objc Virus

Slide 15

Slide 15 text

Objc Virus

Slide 16

Slide 16 text

Objc Virus @objc @objc

Slide 17

Slide 17 text

Build up the Adapter

Slide 18

Slide 18 text

@objc Swift A Swift B Objc C

Slide 19

Slide 19 text

Swift A Swift B Objc C

Slide 20

Slide 20 text

Swift A Swift B Objc C @objc Swift D

Slide 21

Slide 21 text

Promise AnyPromise @objc __AnyPromise

Slide 22

Slide 22 text

What Architecture?

Slide 23

Slide 23 text

The Popular Architectures

Slide 24

Slide 24 text

MVX • MVP • MVVM • VIPER • VIP • etc.

Slide 25

Slide 25 text

Reference • Nelson:漫談 iOS 架構:MVC / MVVM / VIPER 與 Redux • 黃惠勤:從 MVC 到 MVVM,再到 MVVMC 的開發經驗分 享

Slide 26

Slide 26 text

The Clean Architecture

Slide 27

Slide 27 text

–Uncle Bob “Clean architecture is an attempt to integrate all of these architectures into a single actionable idea”

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

Policies Mechanisms

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

Infected

Slide 32

Slide 32 text

–Caio Zullo “None of those acronyms can be considered an architecture but just UI design pattern”

Slide 33

Slide 33 text

MVX: Objc

Slide 34

Slide 34 text

MVX: Objc Adapter

Slide 35

Slide 35 text

MVX: Objc Adapter Core: Swift

Slide 36

Slide 36 text

MVX: Objc Adapter Core: Swift

Slide 37

Slide 37 text

MVX: Objc Adapter Core: Swift MVC MVP MVVM VIPER VIP

Slide 38

Slide 38 text

Apply to Product

Slide 39

Slide 39 text

An app is Full of Pages

Slide 40

Slide 40 text

Objc Objc Swift Swift

Slide 41

Slide 41 text

MVP MVC MVVM VIP

Slide 42

Slide 42 text

Navigate within the Pages

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

Objc Objc Swift Swift Push Push Present

Slide 46

Slide 46 text

Objc Objc Swift Swift Push Push Present

Slide 47

Slide 47 text

Coordinator Pattern

Slide 48

Slide 48 text

Soroush Khanlou

Slide 49

Slide 49 text

VC VC Coordinator A Coordinator B

Slide 50

Slide 50 text

Objc Swift Coordinator A Coordinator B

Slide 51

Slide 51 text

Reusable Views

Slide 52

Slide 52 text

Componentization Architecture

Slide 53

Slide 53 text

The Goal Is • Testability • Reusability • Maintainability • Extensibility

Slide 54

Slide 54 text

Componentization Architectural Pattern • MVP • Presenter uses an interface to call view • Presenter manages the state of the view • MVI • View fires “Intent” events

Slide 55

Slide 55 text

Implementation Problems • A UI Component (view) = a MVP • Handle “intent” events

Slide 56

Slide 56 text

1. Child View Controller

Slide 57

Slide 57 text

No content

Slide 58

Slide 58 text

Reference • d_date: Integrate your app to modern world

Slide 59

Slide 59 text

2. NotificationCenter

Slide 60

Slide 60 text

View NotificationCenter Presenter Event Event

Slide 61

Slide 61 text

Summary

Slide 62

Slide 62 text

Slide 63

Slide 63 text

Pure Swift

Slide 64

Slide 64 text

Pure Swift @objc Swift Adapter

Slide 65

Slide 65 text

MVX: Objc Adapter Core: Swift MVC MVP MVVM VIPER VIP

Slide 66

Slide 66 text

MVX: Objc Adapter Core: Swift SwiftUI

Slide 67

Slide 67 text

Objc Swift Coordinator A Coordinator B

Slide 68

Slide 68 text

Adapter [Objective-C] [Swift]

Slide 69

Slide 69 text

No content

Slide 70

Slide 70 text

–Mars “The adapters and isolation will bring your product a new life.”

Slide 71

Slide 71 text

–Mars “The reference sessions will make your session easier.”

Slide 72

Slide 72 text

References

Slide 73

Slide 73 text

Coordinator • The Coordinator
 http://khanlou.com/2015/01/the-coordinator • How to use the coordinator pattern in iOS apps
 https://www.hackingwithswift.com/articles/71/how-to-use- the-coordinator-pattern-in-ios-apps • Advanced coordinators in iOS
 https://www.hackingwithswift.com/articles/175/advanced- coordinator-pattern-tutorial-ios • MVVMC-SplitViewController
 https://github.com/mgacy/MVVMC-SplitViewController

Slide 74

Slide 74 text

UI Component • droidcon NYC 2018 - Netflix's componentization architecture with RxJava + Kotlin • part I
 https://www.youtube.com/watch?v=dS9gho9Rxn4 • part II
 https://www.youtube.com/watch?v=1cWwfh_5ZQs • sample code
 https://github.com/julianomoraes/componentizationArch • John Sundell - Building component driven UIs (Mobile Era 2016)
 https://vimeo.com/190713343 • Child View Controllers
 https://www.swiftbysundell.com/basics/child-view-controllers/

Slide 75

Slide 75 text

Clean Architecture • Uncle Bob - The Clean Architecture
 https://blog.cleancoder.com/uncle-bob/2012/08/13/the- clean-architecture.html • Essential Developer - Clean iOS Architecture
 https://www.youtube.com/playlist? list=PLyjgjmI1UzlSWtjAMPOt03L7InkCRlGzb • iOS-Clean-Architecture-Example
 https://github.com/frankvalbuena/iOS-Clean- Architecture-Example

Slide 76

Slide 76 text

Statistics • https://www.jetbrains.com/research/devecosystem-2018/ swift-objc/ • https://dzone.com/articles/swift-vs-objective-c-7- benefits-of-swift-developme

Slide 77

Slide 77 text

Q & A Twitter: @marslin_dev