๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๐ŸŽ iOS/Architecture

(4)
[iOS/Architecture] UseCase ํ™œ์šฉ๊ธฐ ์•ˆ๋…•ํ•˜์„ธ์š” ์ œ์ธ์ž…๋‹ˆ๋‹ค :)์ตœ๊ทผ์— ์ง„ํ–‰ํ•œ ๊ฐœ์ธ ํ”„๋กœ์ ํŠธ์˜ ์•„ํ‚คํ…์ฒ˜๋ฅผ MVVM-Clean Architecture ๋กœ ์„ค๊ณ„ํ•˜๊ณ , ๊ฐ ๋ ˆ์ด์–ด์˜ ์—ญํ• ์„ ๋ช…ํ™•ํžˆ ๊ตฌ๋ถ„ํ•ด ์ „์ฒด ์ฝ”๋“œ์˜ ์œ ์ง€๋ณด์ˆ˜์„ฑ์„ ๋†’์ด๋Š” ๋ฐ ์ดˆ์ ์„ ๋งž์ถ”์–ด ๊ฐœ๋ฐœ์„ ํ–ˆ์—ˆ๋Š”๋ฐ์š”,์ด ๊ณผ์ •์—์„œ ํŠนํžˆ UseCase์˜ ์—ญํ• ์— ๋Œ€ํ•ด ๋งŽ์ด ๊ณ ๋ฏผ์„ ํ•œ ๊ฒƒ ๊ฐ™์•„์š”!๊ทธ๋ž˜์„œ ์ œ๊ฐ€ ์ €์˜ ๋ฐฉ์‹๋Œ€๋กœ UseCase๋ฅผ ๊ตฌ์„ฑํ•œ ๋‚ด์šฉ์„ ํ•œ ๋ฒˆ ๊ณต์œ ํ•ด๋ณด๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค.UseCase๋ž€?UseCase ๋ ˆ์ด์–ด์˜ ์—ญํ• ์„ ํ•œ ์ค„๋กœ ์ •์˜ํ•œ๋‹ค๋ฉด ์•„๋ž˜์™€ ๊ฐ™์ด ์ •์˜ํ•  ์ˆ˜ ์žˆ์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.UseCase๋Š” ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง์ด ์œ„์น˜ํ•˜๋Š” ๊ณณ์œผ๋กœ, ์—”ํ‹ฐํ‹ฐ๋กœ ๋“ค์–ด์˜ค๊ณ  ๋‚˜๊ฐ€๋Š” ๋ฐ์ดํ„ฐ ํ๋ฆ„์„ ์กฐ์ •ํ•ฉ๋‹ˆ๋‹ค. ์ด ์ •์˜๋ฅผ ์ข€ ํ’€์–ด์„œ ์ƒ๊ฐํ•ด๋ณผ๊ฒŒ์š”!ํ™”๋ฉด์— ๋ณด์—ฌ์ค„ ๋ฐ์ดํ„ฐ๋ฅผ ์›ํ•˜๋Š” ํ˜•ํƒœ๋กœ ์–ป์œผ๋ ค๋ฉด?1. ๋„คํŠธ์›Œํฌ ํ†ต์‹ ์„ ํ†ตํ•ด DB์— ์žˆ๋Š” ..
[Architecture] Clean Architecture ์•ˆ๋…•ํ•˜์„ธ์š” ์ œ์ธ์ž…๋‹ˆ๋‹ค :) ์œ ์—ฐํ•œ ์„ค๊ณ„์— ๊ด€์‹ฌ์ด ๋งŽ์•„์ง€๋ฉด์„œ ํด๋ฆฐ ์•„ํ‚คํ…์ฒ˜์— ๋Œ€ํ•ด ์ซŒ์ซŒ๋”ฐ๋ฆฌ๋กœ ๊ณต๋ถ€๋Š” ํ•˜๊ณ  ์žˆ์—ˆ์ง€๋งŒ, ๋จธ๋ฆฟ์†์— ํ™•์‹คํ•˜๊ฒŒ ๊ฐœ๋…์ด ์žกํ˜€์žˆ์ง„ ์•Š์€ ์ƒํƒœ์˜€๋Š”๋ฐ.. ์ด์ œ๋Š” ํ”„๋กœ์ ํŠธ์— ์ ์šฉ๊นŒ์ง€ ํ•ด๋ณด๊ณ  ์‹ถ์–ด์„œ ํด๋ฆฐ ์•„ํ‚คํ…์ฒ˜์— ๋Œ€ํ•ด ์ •๋ฆฌ๋ฅผ ํ•ด๋ณด๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค! ์ด๋ฒˆ ๊ฒŒ์‹œ๊ธ€์—์„œ๋Š” Robert C. Martin์˜ The Clean Architecture ๋ผ๋Š” ๊ธ€์„ ๋ฒˆ์—ญํ•ด๋ณด๋ฉด์„œ ํด๋ฆฐ ์•„ํ‚คํ…์ฒ˜ ๊ฐœ๋…์— ๋Œ€ํ•œ ์ •๋ฆฌ๋ฅผ ํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. Clean Architecture๋ž€? ํด๋ฆฐ ์•„ํ‚คํ…์ฒ˜๋Š” Robert C. Martin(aka ์—‰ํด๋ฐฅ, ๋ฐฅ์•„์ €์”จ)์— ์˜ํ•ด ๊ณ ์•ˆ๋œ ์†Œํ”„ํŠธ์›จ์–ด ์•„ํ‚คํ…์ฒ˜ ํŒจํ„ด์ž…๋‹ˆ๋‹ค. ๋ฐฅ์•„์ €์”จ๊ฐ€ ํด๋ฆฐ ์•„ํ‚คํ…์ฒ˜๋ฅผ ๋Œ€์ฒด ์™œ ๋งŒ๋“ค๊ฒŒ ๋˜์—ˆ๋ƒ.. ํ•˜๋ฉด! ๊ธฐ์กด์˜ ์—ฌ๋Ÿฌ ์•„ํ‚คํ…์ฒ˜์—์„œ ์œ ์‚ฌ์„ฑ์„ ์ฐพ์•˜๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค. ๊ธฐ์กด์˜ ์•„ํ‚คํ…์ฒ˜๋“ค์€ ์„ธ..
[Architecture] VIPER ํŒจํ„ด ์•ˆ๋…•ํ•˜์„ธ์š”, ์ œ์ธ์ž…๋‹ˆ๋‹ค! ์ตœ๊ทผ ์‹œ์ž‘ํ•œ ์•„ํ‚คํ…์ฒ˜ ๋ฐ ๋””์ž์ธ ์Šคํ„ฐ๋””์—์„œ ์ฒซ๋ฒˆ์งธ๋กœ ์ฃผ์ œ๋กœ ๋‹ค๋ฃจ์—ˆ๋˜ VIPER ์•„ํ‚คํ…์ฒ˜ ํŒจํ„ด์— ๋Œ€ํ•ด ์ •๋ฆฌํ•ด๋ณด๋ ค ํ•ฉ๋‹ˆ๋‹ค. ๋ฐ”๋กœ ์‹œ์ž‘ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค๐Ÿ˜Š VIPER Pattern์ด๋ž€? View, Interactor, Presenter, Entity, Router์˜ ์•ฝ์ž๋ฅผ ๋”ฐ์™€์„œ VIPER๋ผ๋Š” ์ด๋ฆ„์ด ๋ช…๋ช…๋œ ๋‹จ์ผ์ฑ…์ž„์›์น™ ๊ธฐ๋ฐ˜์˜ ์•„ํ‚คํ…์ณ์ž…๋‹ˆ๋‹ค. ์‘์ง‘๋„๋Š” ๋†’๊ณ  ๊ฒฐํ•ฉ๋„๋Š” ๋‚ฎ์€ ํ˜•ํƒœ๋กœ, ์•„๋ฌด๋ž˜๋„ ๊ฐ๊ฐ์˜ ๊ตฌ๋ถ„์ด ๋งŽ์€ ๋งŒํผ ์—ญํ•  ๋‹จ์œ„์˜ ๊ตฌ๋ถ„์ด ๋ช…ํ™•ํ•ฉ๋‹ˆ๋‹ค. (์ด๊ฒƒ์ด ๋ญ”๊ฐ€ ์žฅ์ ์ด ๋  ์ˆ˜๋„ ๋‹จ์ ์ด ๋  ์ˆ˜๋„ ์žˆ๋Š” ๊ฒƒ ๊ฐ™๊ธดํ•ฉ๋‹ˆ๋‹ค..) ์ดํ•ด๋ฅผ ๋•๊ธฐ ์œ„ํ•ด ๊ทธ๋ฆผ์œผ๋กœ ํ‘œํ˜„ํ•ด๋ดค๋Š”๋ฐ์š”, ํ•˜๋‚˜์”ฉ ์‚ดํŽด๋ด…์‹œ๋‹ค! View : ์–ด๋–ค ํŒจํ„ด์ด๋“  ์‚ฌ์šฉํ•˜๋Š” View ์—ญํ• ์ž…๋‹ˆ๋‹ค. ์ฃผ๋กœ UIViewController, UIView๋“ค์ด ์ด ์—ญํ• ..
[Architecture] MVC, MVP, MVVM ์•„ํ‚คํ…์ฒ˜ ํŒจํ„ด ์•ˆ๋…•ํ•˜์„ธ์š”๐Ÿ˜Š ์˜ค๋Š˜์€ ์•„ํ‚คํ…์ฒ˜ ํŒจํ„ด ๋ช‡๊ฐ€์ง€์— ๋Œ€ํ•ด ์ •๋ฆฌํ•ด๋ณผ๊นŒ ํ•ฉ๋‹ˆ๋‹ค! ์•„ํ‚คํ…์ฒ˜์— ๋Œ€ํ•ด ๊ณต๋ถ€ํ•ด์•ผ๊ฒ ๋‹ค๊ณ  ์ƒ๊ฐํ•œ ์ด์œ ๋Š” MVC ํŒจํ„ด์œผ๋กœ ๊ฐœ๋ฐœํ•˜๋ฉฐ VC๊ฐ€ ๋ชจ๋“  ์—ญํ• ์„ ๋‹ด๋‹นํ•˜๋‹ค๋ณด๋‹ˆ ์ ์  ๋ฌด๊ฑฐ์›Œ์ง€๋Š” ๊ฒƒ์„ ๋Š๊ผˆ๊ณ .. ์ด๋Ÿฌํ•œ MVC ํŒจํ„ด์˜ ๋‹จ์ ์— ๋Œ€ํ•œ ๋Œ€์•ˆ์œผ๋กœ MVVM ํŒจํ„ด์ด ์žˆ๋‹ค๋Š” ๊ฒƒ์„ ์•Œ๊ฒŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ ์ด๋ฒˆ ํฌ์ŠคํŒ…์—์„œ MVC, MVP, MVVM ์•„ํ‚คํ…์ฒ˜ ํŒจํ„ด์— ๋Œ€ํ•ด ์ฐจ์ด์ ์„ ์œ„์ฃผ๋กœ ์ •๋ฆฌํ•ด๋ณด๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค! ์•„ํ‚คํ…์ฒ˜ ํŒจํ„ด์ด๋ž€? ๋จผ์ €, ์•„ํ‚คํ…์ฒ˜ ํŒจํ„ด์ด๋ž€ ๋ฌด์—‡์ผ๊นŒ์š”? ์œ„ํ‚คํ”ผ๋””์•„์— ๋”ฐ๋ฅด๋ฉด, ์•„ํ‚คํ…์ฒ˜ ํŒจํ„ด์ด๋ž€, ์ฃผ์–ด์ง„ ์ƒํ™ฉ์—์„œ์˜ ์†Œํ”„ํŠธ์›จ์–ด ์•„ํ‚คํ…์ณ์˜ ๊ณตํ†ต์ ์ธ ๋ฐœ์ƒ ๋ฌธ์ œ์— ๋Œ€ํ•œ ์ผ๋ฐ˜์ ์ธ, ์žฌ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ํ•ด๊ฒฐ์ฑ…์„ ์˜๋ฏธํ•œ๋‹ค. ์•„ํ‚คํ…์ฒ˜ ํŒจํ„ด์€ ์†Œํ”„ํŠธ์›จ์–ด ๋””์ž์ธ ํŒจํ„ด๊ณผ ์œ ์‚ฌํ•˜์ง€๋งŒ ๋” ํฐ ๋ฒ”์ฃผ์— ์†ํ•œ๋‹ค. ๊ฐ„๋‹จํžˆ ๋งํ•˜๋ฉด, ์•„ํ‚คํ…์ฒ˜ ํŒจ..