---
# System prepended metadata

title: New Life for Your Product - Mars
tags: [iPlayground2019]

---


New Life for Your Product - Mars
===

{%hackmd FGRWt1UuTFKk0wSbGgg-SA %}

> 請從這裡開始

## YouTube
{%youtube 05ZLyvmFiT8 %}

## Slide
{%speakerdeck marslin1220/new-life-for-your-product %}

### Annoying Hybird codebase
* becuase powerful swift
* Hybird with Objc, there are many feature couldn't use well


#### Objc Virus 
* 寫大一堆 `@objc` 橋接關鍵字
* 會污染到整個 codebase
* 用 Adapoter 處理
 ![](https://i.imgur.com/XYOKByM.png)

## solution

### the `MVX` family
- MVP
- MVVM
- VIPER
- VIP
- etc.

### The Clean Architecture
* 實作由內而外
-> Core: Pure Swift -> 程式核心
-> Adapter : 橋接inputs , outputs
-> MVX: Objc -> 利用架構產生外部接口
可參考PromiseKit的實作方式，他利用_AnyPromise層橋接Pure swift <-> Objc的部分
https://github.com/mxcl/PromiseKit

* 用 Coordinator Pattern 作為 Swift 跟 Obj-C 之間的 Adapter

* UI Componet(view) = a MVC
  Child View Controller

* How to handle "Intent" in view
  NotificationCenter

# Summary

### If you want to create a `Swift-ObjC` hybrid project
    * Create major function in `Pure Swift` at first 
    * Use `@objc Swift Adapter` for interface (reference PromiseKit)
        * 先實作一個可以給swift B用的pure swift A
        * 當objc C需要用到swift A時，再實作一個橋接的@objc Swift D
    * Use `Coordinator` pattern for UI flow
    
![](https://i.imgur.com/EhsSNZn.png)


# Reference

## Session

* Nelson：漫談 iOS 架構：MVC / MVVM / VIPER 與 Redux
* 黃惠勤：從 MVC 到 MVVM，再到 MVVMC 的開發經驗分享
* d_date: Integrate your app to modern world

## 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)

## 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/)

## Clean Architecture

* [Uncle Bob - The Clean Architecture](https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html)
* [Youtube Playlist - Clean iOS Architecture](https://www.youtube.com/playlist?list=PLyjgjmI1UzlSWtjAMPOt03L7InkCRlGzb)
* Componentization Architecture

## Sample Code

* [MVVMC-SplitViewController](https://github.com/mgacy/MVVMC-SplitViewController)
* [iOS-Clean-Architecture-Example](https://github.com/frankvalbuena/iOS-Clean-Architecture-Example)

## Statistics

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

###### tags:`iPlayground2019` 
