SlideShare a Scribd company logo
https://github.com/godrm/ChessMate
🤩
Letswift18 워크숍#1 스위프트 클린코드와 코드리뷰
Letswift18 워크숍#1 스위프트 클린코드와 코드리뷰
Letswift18 워크숍#1 스위프트 클린코드와 코드리뷰
Letswift18 워크숍#1 스위프트 클린코드와 코드리뷰
Letswift18 워크숍#1 스위프트 클린코드와 코드리뷰
?
?
?
?
?
Letswift18 워크숍#1 스위프트 클린코드와 코드리뷰
Letswift18 워크숍#1 스위프트 클린코드와 코드리뷰
Letswift18 워크숍#1 스위프트 클린코드와 코드리뷰
API 



SwiftLint

CI
API 



SwiftLint

CI
Best Practices & Styles
✱ Tab vs. Space
✱ Braces Styles
✱ Variable, Function, Class - Naming Rules
✱ Computed Properties vs. Methods
✱ Protocol + Extension + Generic
✱ Value Types vs. Reference Types
Software maintenance is
not 'keep it working like before'.
It is 'keep it being useful in a changing world'
- Jessica Kerr
1.
. .
2.
/ .
3.
.
4.
.
5.
/ .
6.
.
7.
. .
, ,
http://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html
?
+
+
Main - , , ,
Reusability - DRY, components, generics
Reliability - Exception handling and cleanup
Extensibility
Security - , , ,
Performance - , Lazy Loading, ,
Scalability -
Usability -
https://c4model.com
Letswift18 워크숍#1 스위프트 클린코드와 코드리뷰
🤩
A B C D E F G H
8
7
6
5
4
3
2
1
Person
ChessMate System
Email System
App Store
Person
ChessMate System
Email System
ChessMate System
iOS App
Android App
API ServerDatabase
Apple
App Store
Google
Play Store
Person
ChessMate System
Mobile App
AppDelegate
ChessView
Controller
API Server
Network
Manager
APNS Server
Background
View
1. SRP (Single-Responsibility Principle)
( , , ) .
- .
2. OCP (Open-Close Principle)
, .
.
3. LSP (Liskov Substitution Principle)
( ) . ( )
.
4. DIP (Dependency-Inversion Principle)
. ( )
, .
5. ISP (Interface-Segregation Principle)
.
struct InputView {
func readInput() {
print(" .")
let userInput = readLine()
guard let input = userInput else { return }
print(seperateCoordinates(userInput: input))
}
//…
}
struct InputView {
func readLine(prompt: String) -> String {
print(prompt)
let line = readLine()
guard let input = line else { return "" }
return input
}
//…
}
class BackgroundView: UIView {
private let Steps = 8
//
convenience init() { self.init(frame: ChessBackgroundView.centralRect()) }
private static func centralRect() -> CGRect {
let screenRect = UIScreen.main.bounds
let verticalMargin = (screenRect.height - screenRect.width) / 2
return CGRect(x: 0, y: verticalMargin,
width: screenRect.width, height: screenRect.width)
}
override func draw(_ rect: CGRect) {
let width = frame.width / CGFloat(Steps)
let height = frame.height / CGFloat(Steps)
var binaryFlag = false
for y in 0..<Steps {
for x in 0..<Steps {
let boxFrame = CGRect(x: CGFloat(x) * width, y: CGFloat(y) * height,
width: width, height: height)
(binaryFlag ? UIColor.white : UIColor.black).setFill()
UIBezierPath.init(rect: boxFrame).fill()
binaryFlag.toggle()
}
binaryFlag.toggle()
}
}
}
UIScreen
GUI
Engine
ChessMate System
BackgroundView
draw(rect:)
init()
centralRect()
UIScreen
GUI
Engine
ChessMate System
BackgroundView
draw(rect:)
init(frame:)
centralRect()
BackgroundPresenter
Person
ChessMate System
Mobile App
AppDelegate
ChessView
Controller
Background
Presenter
Background
View
Person
ChessMate System
Mobile App
AppDelegate
ChessView
Controller
Background
Presenter
Background
View
Pawn
View
King
View
Queen
View …
View DataSource
View
DataSource
DataSource
<Protocol>
Protocol-Oriented Programming
Piece enum
PieceType
.pawn
.king
.queen
.rook
.bishop
.knight
type
Piece
Pawn
type
PieceType
<Protocol>
King Queen Rook Bishop Knight
Person
ChessMate System
Mobile App
AppDelegate
ChessView
Controller
Background
Presenter
Background
View
Piece
<Protocol>
Piece
Constructor Injection
Setter Injection
Interface Injection
class BackgroundView: UIView {
private var presenter : BackgroundPresenter!
convenience init(presenter: BackgroundPresenter) {
self.init(frame: presenter.centralRect())
self.presenter = presenter
}
}
protocol GameManagerAction {
func positionMap() -> Array<Array<Piece?>>
func defaultFrame(path:(x : Int, y: Int)) -> CGRect
}
class ViewController: UIViewController {
private var manager : GameManagerAction!
func setManager(_ manager : GameManagerAction) {
self.positionManager = manager
}
}
protocol PieceImageSetter {
func setImageBy(piece: Piece)
}
class PieceImageView: UIImageView, PieceImageSetter {
func setImageBy(piece: Piece) {
self.image = piece.type.image(color: piece.color.rawValue)
}
}
protocol GameManagerAction {
func positionMap() -> Array<Array<Piece?>>
}
protocol GameManagerGeometric {
func defaultFrame(for: (x : Int, y: Int)) -> CGRect
}
class ViewController: UIViewController {
private var positionManager :
(GameManagerAction & GameManagerGeometric)!
func setManager(_ manager :
GameManagerAction & GameManagerGeometric) {
self.positionManager = manager
}
protocol GameManagerAction {
func positionMap() -> Array<Array<Piece?>>
func defaultFrame(path:(x : Int, y: Int)) -> CGRect
}
Person
ChessMate System
Mobile App
AppDelegate
ChessView
Controller
Background
Presenter
Background
View
Game
Manager
<Action>
Game
Manager
Geometric
.
Don’t get it, Just ask them.
struct GamePositionManager {
var positionMap = Array<Array<Piece?>>()
struct GamePositionManager {
var positionMap = Array<Array<Piece?>>()
Letswift18 워크숍#1 스위프트 클린코드와 코드리뷰
(Driver)(Navigator)
http://cameracourage.com/2012/11/what-does-a-rally-co-driver-do/
• .

• .

• , .

• .

• .

• , , !

• .

• .

• .

• ( 10 ~20 ) .

• TDD . ( …)
• .

• .

• .

• .

• .
, .

• .

• .

• .

• : .
• .

• ' ' .

• .

• * * .

• .

• .

• .

• .

• .

• .
• review .

• 

• , 

• 😱

• 

• 

• . .
https://github.com/godrm/ChessMate
Letswift18 워크숍#1 스위프트 클린코드와 코드리뷰

More Related Content

PDF
스위프트를 여행하는 히치하이커를 위한 스타일 안내
PDF
Letswift19-clean-architecture
PDF
Simulator customizing & testing for Xcode 9
PDF
[Let'Swift 2019] 실용적인 함수형 프로그래밍 워크샵
PDF
EcmaScript 6 - The future is here
PDF
Rust ⇋ JavaScript
PDF
JavaScript and the AST
PDF
Elm: give it a try
스위프트를 여행하는 히치하이커를 위한 스타일 안내
Letswift19-clean-architecture
Simulator customizing & testing for Xcode 9
[Let'Swift 2019] 실용적인 함수형 프로그래밍 워크샵
EcmaScript 6 - The future is here
Rust ⇋ JavaScript
JavaScript and the AST
Elm: give it a try

What's hot (20)

PDF
Cycle.js: Functional and Reactive
PDF
Minimizing Decision Fatigue to Improve Team Productivity
PDF
ES6 - Next Generation Javascript
PDF
ECMAScript 6
PDF
Compose Async with RxJS
PDF
An Intro To ES6
PDF
JavaScript ES6
PDF
FalsyValues. Dmitry Soshnikov - ECMAScript 6
PDF
Building fast interpreters in Rust
ODP
ES6 PPT FOR 2016
PDF
ES2015 workflows
PDF
Explaining ES6: JavaScript History and What is to Come
PDF
Introduction into ES6 JavaScript.
PDF
ES2015 (ES6) Overview
PDF
Your code is not a string
PDF
AST Rewriting Using recast and esprima
PPTX
AST - the only true tool for building JavaScript
PPTX
JavaScript - i och utanför webbläsaren (2010-03-03)
PPTX
ES6 Overview
PDF
Writing Clean Code in Swift
Cycle.js: Functional and Reactive
Minimizing Decision Fatigue to Improve Team Productivity
ES6 - Next Generation Javascript
ECMAScript 6
Compose Async with RxJS
An Intro To ES6
JavaScript ES6
FalsyValues. Dmitry Soshnikov - ECMAScript 6
Building fast interpreters in Rust
ES6 PPT FOR 2016
ES2015 workflows
Explaining ES6: JavaScript History and What is to Come
Introduction into ES6 JavaScript.
ES2015 (ES6) Overview
Your code is not a string
AST Rewriting Using recast and esprima
AST - the only true tool for building JavaScript
JavaScript - i och utanför webbläsaren (2010-03-03)
ES6 Overview
Writing Clean Code in Swift
Ad

Similar to Letswift18 워크숍#1 스위프트 클린코드와 코드리뷰 (20)

PDF
ChessFidget - You call that chess?
PDF
Swift, via "swift-2048"
PDF
Real World Generics In Swift
PPTX
2048 on swift
PDF
Deep Dive Into Swift
PDF
Introduction to Swift 2
PDF
Introduction to Swift
PDF
Swift Programming
PDF
Swift Introduction
PPT
PDF
Quick swift tour
PPTX
L10 Using Frameworks
PDF
掀起 Swift 的面紗
PDF
Why the Dark Side should use Swift and a SOLID Architecture
PDF
From android/ java to swift (2)
PDF
iOS Game Development With UIKit
PDF
InterConnect: Server Side Swift for Java Developers
PDF
The Swift Compiler and Standard Library
PDF
A realtime classic chess game [proposal]
PDF
A swift introduction to Swift
ChessFidget - You call that chess?
Swift, via "swift-2048"
Real World Generics In Swift
2048 on swift
Deep Dive Into Swift
Introduction to Swift 2
Introduction to Swift
Swift Programming
Swift Introduction
Quick swift tour
L10 Using Frameworks
掀起 Swift 的面紗
Why the Dark Side should use Swift and a SOLID Architecture
From android/ java to swift (2)
iOS Game Development With UIKit
InterConnect: Server Side Swift for Java Developers
The Swift Compiler and Standard Library
A realtime classic chess game [proposal]
A swift introduction to Swift
Ad

More from Jung Kim (13)

PDF
Let'Swift 2019 키노트
PDF
Letswift18 키노트
PDF
개발자를 위한 넓고 얕은 지식
PDF
Let'Swift 17 키노트
PDF
Swift와 Objective-C를 함께 쓰는 방법
PDF
마스터즈 오픈세미나 - 소프트웨어가좋아요
PDF
소프트웨어로 미래를 준비하는 사람들
PDF
Developerway-2016-camp
PDF
Swift internals
PDF
Swift2 smalltalk osxdev
PDF
모바일 트렌드와 iOS
PDF
개발자로 살아가는 길, 그리고 NEXT
PDF
차세대컴파일러, VM의미래: 애플 오픈소스 LLVM
Let'Swift 2019 키노트
Letswift18 키노트
개발자를 위한 넓고 얕은 지식
Let'Swift 17 키노트
Swift와 Objective-C를 함께 쓰는 방법
마스터즈 오픈세미나 - 소프트웨어가좋아요
소프트웨어로 미래를 준비하는 사람들
Developerway-2016-camp
Swift internals
Swift2 smalltalk osxdev
모바일 트렌드와 iOS
개발자로 살아가는 길, 그리고 NEXT
차세대컴파일러, VM의미래: 애플 오픈소스 LLVM

Recently uploaded (20)

DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Spectroscopy.pptx food analysis technology
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Empathic Computing: Creating Shared Understanding
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Encapsulation theory and applications.pdf
PDF
Approach and Philosophy of On baking technology
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
The AUB Centre for AI in Media Proposal.docx
20250228 LYD VKU AI Blended-Learning.pptx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
The Rise and Fall of 3GPP – Time for a Sabbatical?
Machine learning based COVID-19 study performance prediction
Spectroscopy.pptx food analysis technology
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Diabetes mellitus diagnosis method based random forest with bat algorithm
Empathic Computing: Creating Shared Understanding
Reach Out and Touch Someone: Haptics and Empathic Computing
Review of recent advances in non-invasive hemoglobin estimation
Chapter 3 Spatial Domain Image Processing.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Encapsulation theory and applications.pdf
Approach and Philosophy of On baking technology
“AI and Expert System Decision Support & Business Intelligence Systems”

Letswift18 워크숍#1 스위프트 클린코드와 코드리뷰