์ฐ๋ฆฌ๋ ์ํํธ์จ์ด๋ฅผ ๊ตฌํํ๋ฉด์ ํ์ฅ์ฑ, ์ ์ง๋ณด์์ฑ์ ์ฒด๊ณ์ ์ผ๋ก ๊ทน๋ณตํ๊ธฐ ์ํด ๋ค์ํ ๊ณ ๋ฏผ์ ํด์๋ค.
๊ทธ๋ฆฌ๊ณ ๋์์ธ ํจํด์ ๊ทธ๋ฌํ ๋ถํธํจ์ ๊ทน๋ณตํ๊ธฐ ์ํด์ ๋ค์ํ ๋ฐฉ๋ฒ์ผ๋ก ํ์ํด์๋ค.
๋ฌผ๊ฑด์ ์์ฐํ๊ธฐ ์ํด ๊ฐ์ฅ ํจ์จ์ด ์ข์ ๋ฐฉ๋ฒ.
์ฆ ํจํด, ์ํํธ์จ์ด์์๋ ๊ทธ๋ฌํ ๊ฒ๋ค์ ๋์์ธ ํจํด์ด๋ผ ๋ถ๋ฅด๊ณ ๋ง์ ๊ฐ๋ฐ์๋ค์ ํ์ฅ์ฑ๊ณผ ์ ์ง๋ณด์์ฑ์ ์ํด ๋์์ธ ํจํด์ ๋ฐ๋ฅด๊ณ ์ ํ๋ค. ๊ฐ์ฅ ๋จ์ํ๋ฉด์ ๋๋ฆฌ ์ฌ์ฉ๋๋ฉฐ, ์น์์ ์์ง๊น์ง๋ ์ฌ์ฉ ์ค์ธ MVCํจํด, ๊ทธ๋ฆฌ๊ณ MVC์์์ ๋จ์ ์ ๊ทน๋ณตํ๊ธฐ ์ํด ํ์๋ MVPํจํด ๊ทธ๋ฆฌ๊ณ MVC์์ ๋ ํ ๋ฒ ํ์๋์ด ์์กด์ฑ ๋ถ๋ถ์ ์ต์ํ์ํจ MVVM ํจํด๊น์ง, ์๋๋ฅผ ๊ฑฐ๋ญํ๋ฉด์ ๊ทธ ์๋์ ์ฌ์ฉํ๋ Web์ด๋ App ๋ฑ ๊ณผ ๊ฐ์ ์๋น์ค์์ ์๊ตฌํ๋ ํจํด์ด ์๊ณ , ์์ 3๊ฐ์ง ํจํด์ ๊ทธ์ ๋ฐ๋ผ ํ์ํ ๋ํ์ ์ธ ๋์์ธ ํจํด๋ค์ด๋ค.
์ค๋์ ๊ทธ์ค์ ๋๋ถ๋ถ ๋ชจ๋ฐ์ผ ๊ฐ๋ฐ ์ํคํ ์ฒ์์ ๊ถ์ฅํ๊ณ ์๋ MVVM์ ์์๋ณด๊ณ ์ ํ๋ค.
1. MVVM
MVVM ํจํด์ด๋ Model, View, ViewModel์ ์ค์๋ง๋ก ํ๋์ ์ํํธ์จ์ด๋ฅผ ์ต๋ํ ์์ ๋จ์๋ก ๋๋์ด ๋ง์น Modulํ๋ฅผ ํ์ฑํ๋ฏ, ํ ์คํธ๊ฐ ์ฝ๊ณ ๊ด๋ฆฌํ๊ธฐ๊ฐ ์ฌ์ด ๊ตฌ์กฐ๋ฅผ ๋ชฉํ๋ก ํ ๋์์ธ ํจํด์ด๋ค.
๊ธฐ์กด์ MVC ํจํด์์ ํ์๋์ด ๋ง๋ค์ด์ง ํจํด์ธ๋ฐ, Model๊ณผ View ๊ฐ์ ์์กด์ฑ ๋ฌธ์ ๋ฅผ ๊ทน๋ณตํ์ ๋ฟ๋ง ์๋๋ผ, Controller์ View ๊ฐ์ ์์กด์ฑ๋ ์ต์ํ๋ฅผ ํ ์ ์๋ค๋ ์ฅ์ ์ด ์๋ค.
1) ๊ตฌ์กฐ
์๋์ ๋์ํ๋ฅผ ํตํด MVVMํจํด์ ๊ตฌ์กฐ๋ฅผ ํ์ ํด๋ณด๋๋ก ํ๊ฒ ๋ค.
Model: ๋ฐ์ดํฐ๋ค์ ๋ณด๊ด, ์ฒ๋ฆฌ ๋ฑ์ ์ํํ๋ ๋ถ๋ถ์ด๋ค.
View: ์ฌ์ฉ์์๊ฒ ๋ณด์ด๊ณ ์ฌ์ฉ์์ ์ํธ์์ฉ์ ์ํํ๋ ๋ถ๋ถ์ด๋ค.
ViewModel: View๋ฅผ ํํํ๊ธฐ ์ํด ํ์ํ ๋ฐ์ดํฐ๋ฅผ ์ค๋นํ๊ณ ์ด๋ฒคํธ๊ฐ ๋ฐ์ํ ๊ฒฝ์ฐ Model์ ์ด๋ฒคํธ๋ฅผ ์ ๋ฌํ์ฌ ๋ณํ๋ฅผ ์ ์ฉํ๋ ์ญํ ์ ์ํํ๋ค. ๋ํ View์ ๋ํ ์ด๋ ํ ์ ๋ณด๋ ๊ฐ์ง์ง ์์ผ๋ฉฐ View์ ๋ํ ์์กด์ฑ์ด ์๋๋ก ํ๋ค. ์ค์ง View๊ฐ ์์์ ViewModel์ ์๋ ์ ๋ณด๋ฅผ ํ์ธํ ๋ฟ์ด๋ค.
2) ์ฅ์
MVVM๋ชจ๋ธ์ ๊ฐ์ฅ ํฐ ์ฅ์ ์ ์๋ฌด๋๋ View๋ก๋ถํฐ ๋ ๋ฆฝ์ ์ด๊ธฐ ๋๋ฌธ์ ๋ณ๋๋ก ViewModel๋ง์ ๋ผ์ด๋ด ํ ์คํธ๋ฅผ ํ ์ ์๊ณ , ํ ๊ฐ์ ViewModel๋ง์ผ๋ก ์ฌ๋ฌ ๊ฐ์ View์ ํ์ฉ์ ํ ์ ์๋ค๋ ์ฅ์ ์ด ์๋ค. ๊ธฐ์กด์ MVC ํจํด์ฒ๋ผ View๋ฅผ ์ํ Controller๋ฅผ ๋งค๋ฒ ๋ฐ๋ก๋ฐ๋ก ๋ง๋ค ํ์๊ฐ ์์ผ๋ฉฐ ๊ทธ๋งํผ View๊ฐ ํผ์ UI์๋ฌด๋ฅผ ์ถฉ์คํ๊ฒ ์ํํ ์ ์๋๋ก ๋์์ค๋ค๋ ์ ์ด ์๋ค.
2. Flutter์์์ MVVM
Flutter๋ ๋ชจ๋ฐ์ผ ์ฑ์ ๋์์ธ ํจ๋ฌ๋ค์์ ๋ฐ๋ผ๊ฐ๊ธฐ ๋๋ฌธ์ ๊ทธ๊ณณ์์ ์ฌ์ฉํ๋ ๋ํ์ ์ธ ํจํด๋ค๋ ๋๋ถ๋ถ MVVM์ ํ์ค์ผ๋ก ๋๊ณ ์๋ค. Provider์ BLoC ๊ฒฝ์ฐ Flutter์ ์ํ ๊ด๋ฆฌ๋ฅผ ์ํ ๋ํ์ ์ธ ํจํค์ง์ด๊ณ View์ ViewModel์ด ์๋ก ๋ ๋ฆฝ์ ์ด๋ฉฐ ViewModelํ๋๋ก ์ฌ๋ฌ View์ ํ์ํ ์ ์๋ฏ์ด, Provider์ Bloc ๋ Widget๊ณผ ๋ ๋ฆฝ์ ์ด๊ธฐ ๋๋ฌธ์ ํ ๊ฐ์ ์ํ๋ง์ผ๋ก ์ฌ๋ฌ ๊ฐ์ Widget์ ํ์ฉํ ์๊ฐ ์๋ค.
3. ๊ฒฐ๋ก
์ฌ์ค MVC๋ฅผ ๊ฐ์ ํ ๋ฒ์ ์ด๋ผ๊ณ ์๊ฐํ๋ฉฐ MVVM์ ๋ฌด์กฐ๊ฑด ๋ฐ๋ผ์ผ ํ๋ค๊ณ ๋ ์๊ฐํ๊ฒ ์ง๋ง, MVVM์ ๋ชจ๋ํ์ ๋ถํด๋ฅผ ์ด์ ์ผ๋ก ๋ง์ถ๊ณ ์๊ธฐ ๋๋ฌธ์ ๋์ ๋ฐ๋ผ์๋ ์ฑ์ ๋ ๋ณต์กํ๊ฒ ๋ง๋ค ๊ฐ๋ฅ์ฑ์ด ์๋ค. ๋ง์ฝ์ ๊ฐ๋จํ ๋ก์ง์ผ๋ก ๊ตฌํํ ๋ช ๊ฐ์ ํ๋ฉด์ผ๋ก ๊ตฌ์ฑ๋ ์ฌํํ ์ฑ์ ๊ฒฝ์ฐ MVCํจํด ๋ง์ผ๋ก ๊ตฌํํ๋ ๊ฒ์ด ์ข์ ์๋ ์๋ค. ๋ฐ๋ฉด์ ๋ฐ์ดํฐ์ ๋ฐ์ธ๋ฉ์ ์์ฃผ๋ก ํ ์ฑ์ ๊ฒฝ์ฐ MVVM์ ๋์ฑ ๋น ๋ฅธ ๊ฐ๋ฐ ์๋์ ์ ์ ์ฝ๋๋ก๋ ํจ์ฌ ์์ํ ์ ์ง๋ณด์๋ฅผ ๊ฐ๋ฅํ๊ฒ ๋ง๋ค์ด ์ค ๊ฒ์ด๋ค.
์ด๋ค ๋์์ธ ํจํด์ ์ฌ์ฉํ๋ ํ๋จ์ ๋ณธ์ธ์ ๋ชซ์ด๋ค. ํ์ง๋ง ๋์ ๋ฐ๋ผ ์๋ง์ ๋์์ธ ํจํด์ ๋ถ๋ช ์กด์ฌํ๊ธฐ ๋๋ฌธ์ ํญ์ ์ค์ฉ์ ์ธ ๊ด์ ์์ ๋์์ธ ํจํด์ ์ฌ์ฉํ๋ ๊ฒ์ด ์ข์ ๊ฒ์ด๋ค.
'๐ฌ ๊ฐ๋ฐ์ด๋ก ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๊ฐ๋ฐ์ด๋ก ] JWT (Json Web Token) ์ ๋ํ ์ดํด (0) | 2022.07.12 |
---|