Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
RIBs でのダイエット
Search
TatsunoriKuri
February 13, 2020
Programming
1
550
RIBs でのダイエット
TatsunoriKuri
February 13, 2020
Tweet
Share
More Decks by TatsunoriKuri
See All by TatsunoriKuri
アプリの終活 〜その後〜
kuritatu18
1
2k
タクシーアプリ「GO」でApp Clipを使えるようにしてみる 〜Engineer Challenge Weekでの取り組み〜
kuritatu18
0
160
UIKit ベースの大規模なプロジェクトへの SwiftUI 導入
kuritatu18
3
5k
アプリの終活
kuritatu18
2
1.4k
Other Decks in Programming
See All in Programming
タクシーアプリ『GO』のリアルタイムデータ分析基盤における機械学習サービスの活用
mot_techtalk
6
1.7k
ECS Service Connectのこれまでのアップデートと今後のRoadmapを見てみる
tkikuc
2
260
「今のプロジェクトいろいろ大変なんですよ、app/services とかもあって……」/After Kaigi on Rails 2024 LT Night
junk0612
5
2.2k
Laravel や Symfony で手っ取り早く OpenAPI のドキュメントを作成する
azuki
2
130
OSSで起業してもうすぐ10年 / Open Source Conference 2024 Shimane
furukawayasuto
0
110
よくできたテンプレート言語として TypeScript + JSX を利用する試み / Using TypeScript + JSX outside of Web Frontend #TSKaigiKansai
izumin5210
7
1.8k
Make Impossible States Impossibleを 意識してReactのPropsを設計しよう
ikumatadokoro
0
300
Less waste, more joy, and a lot more green: How Quarkus makes Java better
hollycummins
0
120
「天気予報があなたに届けられるまで」 - NIFTY Tech Talk #22
niftycorp
PRO
0
100
Amazon Bedrock Agentsを用いてアプリ開発してみた!
har1101
0
350
romajip: 日本の住所CSVデータを活用した英語住所変換ライブラリを作った話
sangunkang
0
490
OnlineTestConf: Test Automation Friend or Foe
maaretp
0
120
Featured
See All Featured
Why Our Code Smells
bkeepers
PRO
334
57k
Ruby is Unlike a Banana
tanoku
97
11k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.7k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Site-Speed That Sticks
csswizardry
0
41
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
250
21k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
380
Producing Creativity
orderedlist
PRO
341
39k
The Pragmatic Product Professional
lauravandoore
31
6.3k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
329
21k
Transcript
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved RIBs
でのダイエット
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved ⾃⼰紹介
2 • Tatsunori Kuri (@kuritatu18) • iOS app Developer • JapanTaxi (2018.9 ~)
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved 今⽇話すこと
3 - 1.RIBsとは - 2. 画⾯ が複雑なときのダイエット⽅法 - 3.ロジックが複雑なときのダイエット⽅法 - 4.まとめ
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved RIBs
との出会い 4 応募 2018.4 2018.6 内定 2018.9.12 2018.9.16 ⼊社 v4リニューアル RIBs 採⽤
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved RIBs
とは 5
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved RIBs
とは 6 (https://github.com/uber/RIBs/wiki より)
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved RIBs
のコンポーネント 7 - Router - RIB のルーティング - Interactor - ビジネスロジックを持つ - View(Presenter) - レイアウト、ユーザー操作の処理
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved RIBs
のコンポーネント 8 - Builder - RIB内の構成要素 Router, Interactor, ViewController と ⼦RIB Builderのインスタンス化 - RIB 内部への依存性の注⼊と、RIB 間の依存関係の解決
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved RIB
内のコミュニケーション 9 Router Interactor View Controller Builder Routing Presentable PresentableListener Build()
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved RIB
のルーティングとライフサイクル 10 Child RIB Router Interactor View Controller Builder Parent RIB Router Interactor View Controller Builder Child RIB の Router を attach
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved RIB
のルーティングとライフサイクル 11 Child RIB Router load() Interactor View Controller Builder Parent RIB Router Interactor View Controller Builder Child RIB の Router を attach
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved RIB
のルーティングとライフサイクル 12 Child RIB Router load() Interactor activate() View Controller Builder Parent RIB Router Interactor View Controller Builder Child RIB の Router を attach
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved RIB
のルーティングとライフサイクル 13 Child RIB Router Interactor View Controller Builder Parent RIB Router Interactor View Controller Builder Child RIB の Router を detach
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved RIB
のルーティングとライフサイクル 14 Child RIB Router Interactor deactivate() View Controller Builder Parent RIB Router Interactor View Controller Builder Child RIB の Router を detach
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved RIB間のコミュニケーション
15 Child RIB Router Interactor View Controller Builder Parent RIB Router Interactor View Controller Builder Listener経由で 親RIBの処理を呼ぶ
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved 16
https://blog.japantaxi.co.jp/2018/12/09/1991
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved RIBs
の特徴:ツリー構造 17 ※注⽂導線の⼀部抜粋:2020年2⽉6⽇時点
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved 18
https://github.com/srea/RIBsTreeViewerClient
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved 画⾯が複雑になってきたとき
19
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved RIBs
× MicroViewController 20
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved MicroViewControllerとは
21 https://www.icloud.com/keynote/0vgTYDXyHQTd0l1FKTiF1jT7g#MicroViewController-en
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved ⼦ViewController
の追加 22 - View - StackView
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved 利⽤例
23
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved 注⽂詳細画⾯
24
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved 注⽂詳細画⾯のViewHierarchy
25
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved 注⽂詳細画⾯のViewHierarchy
26
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved RIBs
× MicroViewController 27 - Builder.build()
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved RIBs
× MicroViewController 28 - Builder.build()
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved RIBs
× MicroViewController 29 - Builder.build()
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved RIBs
× MicroViewController 30 - ViewControllable - Router.Init()
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved RIBs
× MicroViewController 31 - Router.didLoad()
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved RIBs
× MicroViewController 32 - Router.didLoad()
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved ViewHierarchy
と RIBsツリー 33
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved 画⾯全体は複雑でも
1つ1つはスリムになった 34
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved ロジックが複雑になってきたとき
35
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved View
の無い RIB に切り出す 36
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved View
の無いRIB 37
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved View
の無いRIB の追加 38 Owns corresponding view の チェックを外す ViewController の無い RIB が作成される Templete から RIB を選択
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved RIB
の分割前 39 Parent RIB Router Interactor ・処理A ・処理B ・処理C View Controller Builder
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved RIB
の分割後 40 Parent RIB Router Interactor ・処理A View Controller Builder B Child RIB Router Builder Interactor ・処理B C Child RIB Router Builder Interactor ・処理C B Child Listener C Child Listener
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved 利⽤例
41
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved 乗⾞地選択画⾯
42
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved 乗⾞地選択画⾯の下の部分
43
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved View
の無い RIB 44
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved View
の無い RIB 45 地図を動かした際の緯度/経度でAPI から住所を取得するRIB
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved View
の無い RIB 46 APIから乗⾞の禁⽌エリア取得と禁⽌ エリア内かの判定をするRIB
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved View
の無い RIB 47 次の画⾯に必要な情報をAPIから取得 するRIB
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved View
の無い RIB 48 View の無いRIBから別のViewのある RIB にルーティングすることもある
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved 複雑なロジックを分散することで
1つ1つはスリムになった 49
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved まとめ
50 - 画⾯とロジックの両⾯からダイエットをすることが可能 - ViewController の平均⾏数:154、500⾏超え1つ - Interactorの平均⾏数:141、500⾏超え2つ - 1つ1つの RIB がスリムになる - 責務が明確になる - 追加、修正による影響が最⼩限に - テストが書きやすい
Proprietary and Confidential ©2017 JapanTaxi, Inc. All Rights Reserved RIBs
とっても良いですよ 51
จষɾը૾ͷ༰ͷແஅసࡌٴͼෳͷߦҝ͝ԕྀ͍ͩ͘͞ɻ Proprietary and Confidential ©2020 JapanTaxi, Inc. All Rights Reserved
˟102-0094ɹ౦ژઍా۠لඌҪொ3-12 3-12 Kioicho Chiyoda-ku, Tokyo 102-0094 Japan TEL 03-6265-6265ɹFAX 03-3239-8115 www.japantaxi.co.jp