Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
UI State Modeling 어떤게 좋을까?
Youngjik Yoon
May 14, 2022
Programming
1
220
UI State Modeling 어떤게 좋을까?
Youngjik Yoon
May 14, 2022
Tweet
Share
Other Decks in Programming
See All in Programming
Let's make a contract: the art of designing a Java API
mariofusco
0
160
Licences open source : entre guerre de clochers et radicalité
pylapp
1
260
iOSアプリの技術選択2022
tattn
6
2.4k
heyにおけるSREの大切さ~マルチプロダクト運用の「楽しさ」と「難しさ」および今後の展望~
fufuhu
3
1.6k
Kueue入門/Kueue Introduction
bells17
0
510
既存のプロジェクトにKMMを導入するための対応策
martysuzuki
2
300
Explore Java 17 and beyond
josepaumard
3
650
Milestoner
bkuhlmann
1
200
Modern Web Apps with Spring Boot, Angular & TypeScript
toedter
12
14k
Go API クライアントの実装 〜Go Conference に載せれなかったTIPS〜
yyoshiki41
0
190
Is Rust a great language for building Kubernetes ecosystem
deepu105
0
140
Nix for Scala folks
kubukoz
0
120
Featured
See All Featured
Building Applications with DynamoDB
mza
83
4.6k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
236
1M
Docker and Python
trallard
27
1.5k
A better future with KSS
kneath
225
15k
The Art of Programming - Codeland 2020
erikaheidi
31
5.8k
Product Roadmaps are Hard
iamctodd
34
6.1k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
498
130k
How to name files
jennybc
39
58k
Teambox: Starting and Learning
jrom
121
7.6k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
103
16k
Intergalactic Javascript Robots from Outer Space
tanoku
261
25k
Six Lessons from altMBA
skipperchong
14
1.3k
Transcript
UI State Modeling 윤영직 | PRND 컴퍼니 안드로이드 개발자 어떤게
좋을까?
ViewModel에서 UI State를 어떻게 처리하고 있나요?
UI State? 앱에서 사용자에게 표시하는 정보 사용자가 보는 항목이 UI라면
UI 상태는 앱에서 사용자가 봐야 한다고 지정하는 항목 isLoading = true “홍길동” name = “홍길동”
UI State? 쉽게 생각해서 우리가 ViewModel에서 만드는 그 코드들
공식문서 코드랩 블로그 우리회사 다른회사 프로젝트 코드를 볼 때마다 방법이
모두 다르다!! sealed class data class
https://github.com/laco-dev/sample-StateModeling
None
UI State 여러개로 처리하기
None
None
None
None
None
None
None
None
None
None
장점 - 각자의 상태가 서로 영향을 주지 않는다 - 코드
작성 난이도가 다소 쉽다 단점 - 변경을 누락해서 개발자 실수로 이어지기 쉽다 - 특정 이벤트가 어떤 상태 변화를 만드는지 파악이 어렵다 - 코드 가독성이 안좋다 UI State 여러개로 처리하기
data class 하나로 만들기
None
None
None
None
None
None
None
None
None
None
data class 하나로 만들기 장점 - data class 특성을 이용할
수 있다 - 부분적인 업데이트가 편리하다 - 상태에 필요한 로직을 클래스에 위임할 수 있다 단점 - 하나의 상태만 변경해도 모든 곳에 전파된다 (데이터 바인딩? 이해도와 숙련도) - 클래스로 분리하기 위한 설계 능력 요구
sealed class로 상태 분리하기
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
sealed class로 상태 분리하기 장점 - sealed class - 표현하고자
하는 상태가 클래스와 1:1 대응된다 - 가독성이 좋다 단점 - 상태의 복잡도와 클래스 개수가 비례한다 - 화면 전체를 만드는 경우보다 아이템 상태를 만드는데 유리하다 - xml로 할 경우 커스텀 뷰로 만들거나 복잡한 바인딩 어댑터가 요구될 수 있음
UiState 일반화하기
None
None
None
None
None
None
None
장점 - 시스템을 만들기 좋다 - 보일러 플레이트 코드를 줄일
수 있다 (가독성이 좋다?) - 아키텍쳐와 같이 사용할 수 있다 ex) https://github.com/airbnb/mavericks(매버릭스), TCA 아키텍쳐 등 단점 - 구현 난이도가 높다!! - 시스템과 약간만 달라져도 대응하기 어려워 진다 - 사용하기 위해서는 반드시 팀을 설득해야 한다 UiState 일반화하기
UiState 삼형제다 UiState 삼형제! data class 좋아하는 녀석 copy 함수
못참지 sealed class 좋아하는 녀석 Base에 이것저것 넣어서 슈퍼클래스 만드는 녀석 코드 짧은게 좋아서… 정답은 없다 테스트 한 번 짜보세요
ViewModel에서 UI State를 어떻게 처리하고 있나요?