Notice
Recent Posts
Recent Comments
Link
๊ด€๋ฆฌ ๋ฉ”๋‰ด

lgvv98

Clean Architecture Swift #2 ๋ณธ๋ฌธ

apple/๐Ÿก DesignPattern & Architecture

Clean Architecture Swift #2

๐Ÿฅ• ์บ๋Ÿฟ๋งจ 2022. 9. 29. 18:48

Clean Architecture Swift #2

 

์—ฌ๊ธฐ๋ถ€ํ„ฐ๋Š” ํด๋ฆฐ ์•„ํ‚คํ…์ณ ์ฝ”๋“œ ๋ถ„์„ํ•œ ๋‚ด์šฉ์„ ๋ฐ”ํƒ•์œผ๋กœ ์˜ˆ์ œ๋ฅผ ๋งŒ๋“ค์–ด๋ณด๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค.

 

ํด๋ฆฐ ์•„ํ‚คํ…์ณ ์—ฐ์Šต์„ ์œ„ํ•ด ReactorKit + Moya๋ฅผ ์‚ฌ์šฉ

 

CleanArchitecture.zip
0.40MB

๐ŸŒฟ term ๐ŸŒฟ

DTO(Data Transfer Object)
๊ณ„์ธต ๊ฐ„ ๋ฐ์ดํ„ฐ ๊ตํ™˜์„ ์œ„ํ•ด ์‚ฌ์šฉํ•˜๋Š” ๊ฐ์ฒด๋กœ, DTO๋Š” ๋กœ์ง์„ ๊ฐ€์ง€์ง€ ์•Š๋Š” ๋ฐ์ดํ„ฐ ๊ฐ์ฒด๋ฅผ ๊ฐ€์ง„ ํด๋ž˜์Šค

 

(๋ถ„์„ํ•  ํ”„๋กœ์ ํŠธ)

https://github.com/kudoleh/iOS-Clean-Architecture-MVVM

 

GitHub - kudoleh/iOS-Clean-Architecture-MVVM: Template iOS app using Clean Architecture and MVVM. Includes DIContainer, FlowCoor

Template iOS app using Clean Architecture and MVVM. Includes DIContainer, FlowCoordinator, DTO, Response Caching and one of the views in SwiftUI - GitHub - kudoleh/iOS-Clean-Architecture-MVVM: Tem...

github.com

 

 

https://tech.olx.com/clean-architecture-and-mvvm-on-ios-c9d167d9f5b3

 

Clean Architecture and MVVM on iOS

When we develop software it is important to not only use design patterns, but also architectural patterns. There are many different…

tech.olx.com

 

 

When we develop software it is important to not only use design patterns, but also architectural patterns. There are many different architectural patterns in Software Engineering. In mobile software engineering, the most widely used are MVVM, Clean Architecture and Redux patterns.


์šฐ๋ฆฌ๊ฐ€ ์†Œํ”„ํŠธ์›จ์–ด ๊ฐœ๋ฐœํ•  ๋•Œ design patterns ๋ฟ๋งŒ ์•„๋‹ˆ๋ผ architectural patterns ๋˜ํ•œ ์ค‘์š”ํ•ฉ๋‹ˆ๋‹ค.
์†Œํ”„ํŠธ์›จ์–ด ์—”์ง€๋‹ˆ์–ด๋ง์—๋Š” ๋‹ค์–‘ํ•œ architectural patterns์ด ์žˆ์Šต๋‹ˆ๋‹ค.
๋ชจ๋ฐ”์ผ ์†Œํ”„ํŠธ์›จ์–ด ๊ณตํ•™์—์„œ ๊ฐ€์žฅ ๋„๋ฆฌ ์‚ฌ์šฉ๋˜๋Š” ๊ฒƒ์€ MVVM, ํด๋ฆฐ ์•„ํ‚คํ…์ณ ๊ทธ๋ฆฌ๊ณ  Redux ํŒจํ„ด์ž…๋‹ˆ๋‹ค.

 

 

ํด๋ฆฐ ์•„ํ‚คํ…์ณ + MVVM

 

outers layer์—์„œ inner layers๋กœ depedency rule์„ ์ง€ํ‚ค๋Š” ๊ฒƒ์ด ๊ฐ€์žฅ ์ค‘์š”ํ•ฉ๋‹ˆ๋‹ค.

 

๋ชจ๋“  ๊ฒƒ์€ ์„ธ๊ฐœ์˜ ๋ ˆ์ด์–ด๋กœ ์ด๋ฃจ์–ด์ ธ ์žˆ๋‹ค.

 

 

Domain Layer๋Š” ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง์„ ๋‹ด๋‹นํ•ฉ๋‹ˆ๋‹ค. 

Entities, Use Cases, Repository๊ฐ€ ํฌํ•จ๋˜๋ฉฐ, ์ด ๊ณ„์ธต์€ ๋‹ค๋ฅธ ํ”„๋กœ์ ํŠธ ๋‚ด์—์„œ ์žฌ์‚ฌ์šฉ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Domain ๊ณ„์ธต์—๋Š” ๋‹ค๋ฅธ ๊ณ„์ธต์ด ํฌํ•จ๋˜์„œ๋Š” ์•ˆ๋ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค๋ฉด์€ UIKit์ด๋‚˜ SwiftUI ํ˜น์€ ๋ฐ์ดํ„ฐ์˜ Mapping Codable ๋“ฑ์ด ์žˆ์Šต๋‹ˆ๋‹ค.

 

Presentation Layer๋Š” View์™€ ๊ด€๋ จํ•œ ๊ฒƒ๋“ค์„ ๋‹ด๋‹นํ•ฉ๋‹ˆ๋‹ค. View๋Š” ํ•˜๋‚˜ ์ด์ƒ์˜ Use Cases๋ฅผ ์‹คํ–‰ํ•˜๋Š” ViewModel์— ์˜ํ•ด์„œ ์กฐ์ •(Coordinated)๋ฉ๋‹ˆ๋‹ค. 

Presentation ๊ณ„์ธต์€ Domain ๊ณ„์ธต์—๋งŒ ์˜์กดํ•ฉ๋‹ˆ๋‹ค.

 

Data Layerdpsms Repository ๊ตฌํ˜„๊ณผ ํ•˜๋‚˜ ์ด์ƒ์˜ Data Source๊ฐ€ ํฌํ•จ๋ฉ๋‹ˆ๋‹ค.

Repositiries๋Š” ์„œ๋กœ ๋‹ค๋ฅธ Data Source์˜ ๋ฐ์ดํ„ฐ๋ฅผ ์กฐ์ •ํ•˜๋Š” ์—ญํ• ์„ ํ•ฉ๋‹ˆ๋‹ค.

Data ๊ณ„์ธต์€ ์˜ค์ง Domain ๊ณ„์ธต์—๋งŒ ์˜์กดํ•˜๋ฉฐ, Data ๊ณ„์ธต์—์„œ Network ํ†ต์‹ ์„ ํ†ตํ•œ JSON Mapping(a.k.a codable์‚ฌ์šฉ)์„ ํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.

 

 

์˜ˆ์ œ ํ”„๋กœ์ ํŠธ์˜ ๋ฐ์ดํ„ฐ ํ๋ฆ„

 

์œ„์˜ ๊ทธ๋ž˜ํ”„๋ฅผ ๋ณด๋ฉด ๊ฐ ๊ณ„์ธต์˜ ๋ชจ๋“  ์ปดํฌ๋„ŒํŠธ๊ฐ€ Domain Use Case๋ฅผ ํ–ฅํ•ด์„œ ํ๋ฅด๋Š”๋ฐ, Data Repository ๋ถ€๋ถ„์—์„œ ๋ฐ˜์ „๋˜๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค. ์ด๋Š” interfaces(protocols)๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ฐ˜์ „!

 

 

 

โœ… ํด๋ฆฐ ์•„ํ‚คํ…์ณ ์—ฐ์Šต โœ…

Clean Architecture

 

 

 

 

โœ… ๊ฒฐ๊ณผ UI โœ…

๊ฒฐ๊ณผ UI

 

 

 

 

ํด๋ฆฐ ์•„ํ‚คํ…์ณ ์ž‘์„ฑ์ˆœ์„œ ํŒ!

 

1. ์—”ํ‹ฐํ‹ฐ

2. DTO

3. ServiceAPI 

4. Repository 

5. useCase

6. ๋ ˆํฌ์ง€ํ† ๋ฆฌ ์ž„ํ”Œ(๋„คํŠธ์›Œํฌ ์š”์ฒญ ๋ฐ ์ปจ๋ฒ„ํŠธ) 

7. ViewController, Reactor

 

 

 

'apple > ๐Ÿก DesignPattern & Architecture' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

Clean Architecture Swift #1  (0) 2022.09.23
[Swift] Coodinator Pattern  (2) 2022.07.07
[Swift] Command Pattern  (1) 2022.07.05
[Swift] Composite Pattern  (1) 2022.06.15
[Swift] Mediator Pattern  (1) 2022.06.15
Comments