- 快召唤伙伴们来围观吧
- 微博 QQ QQ空间 贴吧
- 文档嵌入链接
- <iframe src="https://www.slidestalk.com/u4656/Ctrip_Kotlin_Multiplatform_Practice?embed" frame border="0" width="640" height="360" scrolling="no" allowfullscreen="true">复制
- 微信扫一扫分享
Kotlin Multiplatform Practice
What we need from Kotlin?
• Data Access Layer
• Business Logic Layer
• IO / File / Network
• Concurrent / Asynchronism / Threads
• UI View Components ? (maybe)
• Tools / Test Automation
展开查看详情
1 .Ctrip Kotlin Multiplatform Practice 陈琦 携程机票研发部
2 .What we need from Kotlin ? • Data Access Layer • Business Logic Layer • IO / File / Network • Concurrent / Asynchronism / Threads • UI View Components ? (maybe) • Tools / Test Automation
3 .MPP4MPP Structure (Multiplatform Project for Multiplatform Project)
4 .MPP4MPP Structure - Why ? (Multiplatform Project for Multiplatform Project) • ⼀一个应⽤用程序中⼀一般不不只⼀一个MPP Module。 • ⼀一个MPP Module需要⽀支持可被另⼀一个MPP Module或Native Module引⽤用。 • Kotlin + stdlib = jar • Kotlin + stdlib + Android API = aar • Kotlin Native + iOS Platform API = KLib / Apple Framework • 参考:kotlin.test, kotlinx.serialization。
5 .VIPER as a Container Architecture Inspired by Uber
6 .Move from MV* to VIPER 理理想与现实 / 历史债代码 / 逐步迁移
7 .VIPER reconstruct priority 1. Entity (Data) - Platform independent 2. Interactor - Platform independent 3. Presenter - Platform independent 4. Router - Platform related 5. View - Platform strong dependent
8 .Entity/Data
9 .Network Protocol Redesign - The old way • Base on Schema (Protobuf / JSON/ XML / Swagger API) • Base on Data Object Declaration (POJO / JavaBean)
10 .Network Protocol Redesign - Kotlin • Advantage: • Kotlin Data Class + Serialization Annotation • One Schema / One Object Declaration / One Source Code • Support Multiple Serialization Format • Disadvantage: • Performance benchmark slower • What is the benefit for Java Service Developer ?
11 .Kotlin Native for iOS Binary Size Integration OCsize Link Size app size framework size Case(Byte) link size OCsize.app Framework Delta delta delta Default 463691 1104029 1337821 Int 464451 1105021 1340245 760 992 2424 Int? 465499 1110061 1343037 1048 5040 2792 Long 466259 1110861 1345325 760 800 2288 Long? 467163 1111533 1347758 904 672 2433 Float 467955 1112317 1350076 792 784 2318 Float? 468875 1112989 1352598 920 672 2522 Double 469683 1117949 1354941 808 4960 2343 Double? 470587 1118637 1357360 904 688 2419 Short 471347 1119437 1359682 760 800 2322 Short? 472251 1120125 1362134 904 688 2452 Byte 473011 1125037 1364421 760 4912 2287 Byte? 473915 1125725 1366830 904 688 2409 String 474819 1130541 1369304 904 4816 2474 String? 475691 1131213 1371741 872 672 2437 ArrayList<An 476675 1132013 1374442 984 800 2701 y>? HashMap<An 477803 1133357 1378236 1128 1344 3794 yAny>? HashSet<Any 478755 1134173 1380899 952 816 2663 >? LinkedHash 479659 1139133 1383539 904 4960 2640 Map<AnyAny LinkedHashS 480563 1139917 1386144 904 784 2605 et<Any>?
12 .Interactor / Presenter - kotlinx.coroutines • kotlinx.coroutines is awesome! • But more complicated with Kotlin Native for iOS. • Still work in progress.
13 .Thank you