SlideShare a Scribd company logo
송치원 (곰튀김)
iamchiwon.github.io
코드 삼분지계
Realism Programmer
三分之計
Code Splitting
Architecture
Benefit
1.중복코드 발생
2.코드를 찾기 어려움
3.수정을 빠트리고 적용할 위험
1.코드의 재사용성 증가
2.협업에 용이
3.수정코드를 빠르게 찾아 적용
Benefit
1.중복코드 발생
2.코드를 찾기 어려움
3.수정을 빠트리고 적용할 위험
1.코드의 재사용성 증가
2.협업에 용이
3.수정코드를 빠르게 찾아 적용
유지관리
불리
유지관리
유리
M V X
Model
Controller
ViewPresenter
ViewModel
역할
M V X
Model
Controller
ViewPresenter
ViewModel
역할
아키텍쳐 == 코드의 배치
Pure Platform
Dependency
Pure Platform
Dependency
Pure Platform
삼분지계
Protocol
Inversion
※ let us: Go! 2020 Summer - Inversion
Platform
Protocol
Pure
class ViewController: UIViewController, PlatformInterface {
var logic: BusinessLogic
@IBOutlet label: UILabel
@IBOutlet button: UIButton
@objc func onButtonSelected(sender: Any) {
logic.getCurrentTime()
}
func updateTime(time: String) {
label.text = time
}
}
protocol PlatformInterface {
func updateTime(time: String)
}
class BusinessLogic {
var platform: PlatformInterface
func getCurrentTime() {
let time = "(Date())"
platform.updateTime(time: time)
}
}
UIKit
Protocol
Pure
class ConsoleApplication: PlatformInterface {
var logic: BusinessLogic
func getTime() {
logic.getCurrentTime()
}
func updateTime(time: String) {
print(time)
}
}
protocol PlatformInterface {
func updateTime(time: String)
}
class BusinessLogic {
var platform: PlatformInterface
func getCurrentTime() {
let time = "(Date())"
platform.updateTime(time: time)
}
}
Platform
Console
Protocol
Pure
class Repository: PlatformInterface {
func fetchData(_ callback: @escaping (Data) -> Void) {
URLSession.shared.dataTask(with: URL() ) { (data, _, _) in
callback(data!)
}
}
}
protocol PlatformInterface {
func fetchData(_ callback: @escaping (Data) -> Void)
}
class BusinessLogic {
var platform: PlatformInterface
func handleData() {
platform.fetchData() { data in
// ... handle data
}
}
}
Platform
URLSession
Protocol
Pure
class Repository: PlatformInterface {
func fetchData(_ callback: @escaping (Data) -> Void) {
let data = UserDefaults.standard.data(forKey: "DATA")
callback(data!)
}
}
protocol PlatformInterface {
func fetchData(_ callback: @escaping (Data) -> Void)
}
class BusinessLogic {
var platform: PlatformInterface
func handleData() {
platform.fetchData() { data in
// ... handle data
}
}
}
Platform
UserDefaults
Protocol
Pure
class NetworkImpl: Network {
func GET(url: URL, callback: @escaping (Data) -> Void) {
URLSession.shared.dataTask(with: url) { (data, _, _) in
callback(data!)
}
}
}
protocol Network {
func GET(url: URL, callback: @escaping (Data) -> Void)
}
class BusinessLogic {
var platform: Network?
func fetchData(urlString: String) {
platform?.GET(url: URL(string: urlString)!) { data in
// ... handle data
}
}
}
Platform
URLSession
Protocol
Pure
class NetworkImpl: Network {
func GET(url: URL, callback: @escaping (Data) -> Void) {
AF.request(url).response { response in
callback(response.data)
}
}
}
protocol Network {
func GET(url: URL, callback: @escaping (Data) -> Void)
}
class BusinessLogic {
var platform: Network?
func fetchData(urlString: String) {
platform?.GET(url: URL(string: urlString)!) { data in
// ... handle data
}
}
}
Platform
Alamofire
Protocol
Pure
Platform
Alamofire
Platform
Protocol
Pure
UIKit
Protocol
Pure
Platform
Console
Protocol
Pure
Platform
URLSession
Protocol
Pure
Platform
UserDefaults
Protocol
Pure
Platform
CoreData
Protocol
Pure
Platform
Realm
Protocol
Pure
Platform
Mock
Platform
Interface
Logic
삼분지계
Platform
Interface
Logic
삼분지계
Model
View
ViewModel
Interface
Summary
1. 아키텍쳐는 코드의 배치다.
2. 코드 삼분지계
•코드는 외부 의존도가 있느냐를 기준으로 나눈다.
•그 사이에는 프로토콜을 두어 역전시킨다.
•Pure, Interface, Platform
3. MVx 에서 M과 x 는 Pure하게 작성하자
END

More Related Content

PPTX
7가지 동시성 모델 - 3장. 함수형 프로그래밍
Hyunsoo Jung
 
PDF
7가지 동시성 모델 4장
HyeonSeok Choi
 
PDF
Protocol Oriented Programming in Swift
SeongGyu Jo
 
PPTX
골때리는 자바스크립트 발표자료
욱진 양
 
PDF
7가지 동시성 모델 - 데이터 병렬성
HyeonSeok Choi
 
PPTX
Angular2 가기전 Type script소개
Dong Jun Kwon
 
PDF
[1B4]안드로이드 동시성_프로그래밍
NAVER D2
 
PDF
잘 알려지지 않은 숨은 진주, Winsock API - WSAPoll, Fast Loopback
흥배 최
 
7가지 동시성 모델 - 3장. 함수형 프로그래밍
Hyunsoo Jung
 
7가지 동시성 모델 4장
HyeonSeok Choi
 
Protocol Oriented Programming in Swift
SeongGyu Jo
 
골때리는 자바스크립트 발표자료
욱진 양
 
7가지 동시성 모델 - 데이터 병렬성
HyeonSeok Choi
 
Angular2 가기전 Type script소개
Dong Jun Kwon
 
[1B4]안드로이드 동시성_프로그래밍
NAVER D2
 
잘 알려지지 않은 숨은 진주, Winsock API - WSAPoll, Fast Loopback
흥배 최
 

What's hot (7)

PDF
함수적 사고 2장
HyeonSeok Choi
 
PPTX
Startup JavaScript 8 - NPM, Express.JS
Circulus
 
PDF
자바8 람다식 소개
beom kyun choi
 
PPTX
파이썬+네트워크 20160210
Yong Joon Moon
 
PPTX
Angular2 router&http
Dong Jun Kwon
 
PDF
KGC 2016 오픈소스 네트워크 엔진 Super socket 사용하기
흥배 최
 
PPTX
Quick & Dirty Tips for x64 hooks
용환 노
 
함수적 사고 2장
HyeonSeok Choi
 
Startup JavaScript 8 - NPM, Express.JS
Circulus
 
자바8 람다식 소개
beom kyun choi
 
파이썬+네트워크 20160210
Yong Joon Moon
 
Angular2 router&http
Dong Jun Kwon
 
KGC 2016 오픈소스 네트워크 엔진 Super socket 사용하기
흥배 최
 
Quick & Dirty Tips for x64 hooks
용환 노
 
Ad

Similar to 20201121 코드 삼분지계 (20)

PDF
[2022]Flutter_IO_Extended_Korea_멀티모듈을활용한플러터클린아키텍처_...
Taekyu Lim
 
PDF
Rx for iOS App. RxMVVM-DataCenter!
SUNGCHEOL KIM
 
PDF
객체지향 설계
준영 조
 
PDF
클린 코드 part2
Minseok Jang
 
PDF
iOS Modular Architecture with Tuist
정민 안
 
PPTX
[부스트캠프 웹・모바일 7기 Tech Talk]오승민_Swift의 Protocol에는 감동이 있다
CONNECT FOUNDATION
 
PDF
CleanSwift 적용기
ssuser86e2971
 
PDF
스위프트 성능 이해하기
Yongha Yoo
 
PDF
I os 2
Sanghoon Han
 
PPTX
Ceh
민웅 이
 
PDF
Clojurescript로 하는 함수형 UI 프로그래밍
Sang-Kyu Park
 
PDF
스프링 코어 강의 1부 - 봄 맞이 준비 운동
Sungchul Park
 
PDF
도메인 주도 개발 4장 도메인의 격리
Choonghyun Yang
 
PDF
iOS 메모리관리
Changwon National University
 
PDF
우아한테크세미나-우아한멀티모듈
용근 권
 
PDF
Droid knights 2019 - (Large-scale App을 위한) Android Architecture 총정리
Sa-ryong Kang
 
PDF
[ETHCon Korea 2019] Kang Hyungseok 강형석
ethconkr
 
PPTX
Golang Project Guide from A to Z: From Feature Development to Enterprise Appl...
Kyuhyun Byun
 
PPT
Uml 세미나
Daniel Shin
 
PDF
MVVM Pattern for Android
taeinkim6
 
[2022]Flutter_IO_Extended_Korea_멀티모듈을활용한플러터클린아키텍처_...
Taekyu Lim
 
Rx for iOS App. RxMVVM-DataCenter!
SUNGCHEOL KIM
 
객체지향 설계
준영 조
 
클린 코드 part2
Minseok Jang
 
iOS Modular Architecture with Tuist
정민 안
 
[부스트캠프 웹・모바일 7기 Tech Talk]오승민_Swift의 Protocol에는 감동이 있다
CONNECT FOUNDATION
 
CleanSwift 적용기
ssuser86e2971
 
스위프트 성능 이해하기
Yongha Yoo
 
I os 2
Sanghoon Han
 
Clojurescript로 하는 함수형 UI 프로그래밍
Sang-Kyu Park
 
스프링 코어 강의 1부 - 봄 맞이 준비 운동
Sungchul Park
 
도메인 주도 개발 4장 도메인의 격리
Choonghyun Yang
 
iOS 메모리관리
Changwon National University
 
우아한테크세미나-우아한멀티모듈
용근 권
 
Droid knights 2019 - (Large-scale App을 위한) Android Architecture 총정리
Sa-ryong Kang
 
[ETHCon Korea 2019] Kang Hyungseok 강형석
ethconkr
 
Golang Project Guide from A to Z: From Feature Development to Enterprise Appl...
Kyuhyun Byun
 
Uml 세미나
Daniel Shin
 
MVVM Pattern for Android
taeinkim6
 
Ad

More from Chiwon Song (20)

PDF
20250425_AI가 코딩하는 시대에 개발자가 되겠다구요_.pdf
Chiwon Song
 
PDF
20250210_AI가 코딩하는시대에 개발자 되기 - Google Slides.pdf
Chiwon Song
 
PDF
20240330_고급진 코드를 위한 exception 다루기
Chiwon Song
 
PDF
요즘 유행하는 AI 나도 해보자 (feat. CoreML)
Chiwon Song
 
PDF
20220716_만들면서 느껴보는 POP
Chiwon Song
 
PDF
20210812 컴퓨터는 어떻게 동작하는가?
Chiwon Song
 
PDF
20200815 inversions
Chiwon Song
 
PDF
20191116 custom operators in swift
Chiwon Song
 
PDF
[20190601] 직업훈련교사_수업의실행_교안
Chiwon Song
 
PPTX
[20190601] 직업훈련교사_수업의실행
Chiwon Song
 
PDF
20190330 immutable data
Chiwon Song
 
PPTX
20190306 만들면서 배우는 IoT / IoT의 이해
Chiwon Song
 
PDF
20181020 advanced higher-order function
Chiwon Song
 
PDF
20180721 code defragment
Chiwon Song
 
PDF
20180310 functional programming
Chiwon Song
 
PDF
20171104 FRP 패러다임
Chiwon Song
 
PDF
스크래치로 시작하는 코딩
Chiwon Song
 
PPTX
메이커운동과 아두이노
Chiwon Song
 
PPTX
아두이노 RC카 만들기
Chiwon Song
 
PPTX
[5] 아두이노로 만드는 IoT
Chiwon Song
 
20250425_AI가 코딩하는 시대에 개발자가 되겠다구요_.pdf
Chiwon Song
 
20250210_AI가 코딩하는시대에 개발자 되기 - Google Slides.pdf
Chiwon Song
 
20240330_고급진 코드를 위한 exception 다루기
Chiwon Song
 
요즘 유행하는 AI 나도 해보자 (feat. CoreML)
Chiwon Song
 
20220716_만들면서 느껴보는 POP
Chiwon Song
 
20210812 컴퓨터는 어떻게 동작하는가?
Chiwon Song
 
20200815 inversions
Chiwon Song
 
20191116 custom operators in swift
Chiwon Song
 
[20190601] 직업훈련교사_수업의실행_교안
Chiwon Song
 
[20190601] 직업훈련교사_수업의실행
Chiwon Song
 
20190330 immutable data
Chiwon Song
 
20190306 만들면서 배우는 IoT / IoT의 이해
Chiwon Song
 
20181020 advanced higher-order function
Chiwon Song
 
20180721 code defragment
Chiwon Song
 
20180310 functional programming
Chiwon Song
 
20171104 FRP 패러다임
Chiwon Song
 
스크래치로 시작하는 코딩
Chiwon Song
 
메이커운동과 아두이노
Chiwon Song
 
아두이노 RC카 만들기
Chiwon Song
 
[5] 아두이노로 만드는 IoT
Chiwon Song
 

20201121 코드 삼분지계