More Related Content
Similar to iOS アプリのメンテナンス性を高めるための基本的な考え方 (20)
iOS アプリのメンテナンス性を高めるための基本的な考え方
- 8. Fat な ViewController の問題点
• 責務が多すぎる
• ⼤大量量のイベントハンド
リング
• ロジックの再利利⽤用が難
しい
Copylight © Classmethod, Inc.
8
- 41. ViewController と Colleague の
間のやりとり
Mediator
ViewController
イベント通知
• Target-‐‑‒Action
• Delegate など
Colleague
UI
状態が変化
Copylight © Classmethod, Inc.
41
- 45. ViewController と Colleague の
間のやりとり
Mediator
イベントを
受信
ViewController
適切切な指⽰示
• プロパティにセット
• メソッド呼び出し
UI
UI
Colleague
Copylight © Classmethod, Inc.
45
- 47. まとめ
• ViewController から情報の表⽰示に関連しないモジュールを切切
り離離す
• 情報の表⽰示に関連しないモジュールは、ViewController など
の情報の表⽰示に関連するモジュールに依存しない
• ViewController は⾃自⾝身が参照するオブジェクトの間の仲介役
を主な役割とする
• ViewController が仲介するオブジェクトは ViewController
経由で連携し、互いの存在について直接意識識しない
Copylight © Classmethod, Inc.
47