SlideShare a Scribd company logo
1 of 22
Download to read offline
twitter.com/@godrm
facebook.com/godrm
?
?
?
?
?
?
+
+
✱ Main - , , ,
✱ Reusability - DRY, components, generics
✱ Reliability - Exception handling and cleanup
✱ Extensibility
✱ Security - , , ,
✱ Performance - , Lazy Loading, ,
✱ Scalability -
✱ Usability -
- SOLID
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)
.
SRP
struct InputView {
func readInput() {
print(" .")
let userCoordinate = readLine()
guard let input = userCoordinate else { return }
print(seperateCoordinates(userInput: input))
}
//…
}
struct InputView {
func readInput() -> String {
print(" .")
let userCoordinate = readLine()
guard let input = userCoordinate else { return "" }
return input
}
//…
}
DI
class MessageListViewController: UITableViewController {
private let loader: MessageLoader
init(loader: MessageLoader) {
self.loader = loader
super.init(nibName: nil, bundle: nil)
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
loader.load { [weak self] messages in
self?.reloadTableView(with: messages)
}
}
}
✱
✱
✱
Interface Protocol Segregation
protocol MyShape {
var resultDescription: String { get }
func calculateOfPosition() -> [MyPoint]
func resultOfMyShape() -> Double
}
struct MyLine: MyShape {
private(set) var pointA = MyPoint()
private(set) var pointB = MyPoint()
func calculateOfPosition() -> [MyPoint] { return [pointA, pointB] }
func resultOfMyShape() -> Double { return calculateOfLength() }
//
var resultDescription: String = {
return " "
}()
}
struct MyPoint: MyShape {
private(set) var x = 0
private(set) var y = 0
func calculateOfPosition() -> [MyPoint] { return [self] }
func resultOfMyShape() -> Double { return 0 }
var resultDescription: String = { return "" }()
}
(before)
Protocol Segregation (after)
protocol MyShape {
func calculateOfPosition() -> [MyPoint]
func resultOfMyShape() -> Double
}
protocol MyDescription {
var resultDescription: String { get }
}
struct MyLine: MyShape, MyDescription {
private(set) var pointA = MyPoint()
private(set) var pointB = MyPoint()
func calculateOfPosition() -> [MyPoint] { return [pointA, pointB] }
func resultOfMyShape() -> Double { return calculateOfLength() }
var resultDescription: String = {
return " "
}()
}
struct MyPoint: MyShape {
private(set) var x = 0
private(set) var y = 0
func calculateOfPosition() -> [MyPoint] { return [self] }
func resultOfMyShape() -> Double { return 0 }
}
Optional
guard let y = x { ... }
//
let image = UIImage(named: "Background") if image == nil {
print("Image not loaded ")
return
}
let size = image!.frame.size.scaled(by: 2.0)
//
let image = UIImage(named: selectedImageName)!
guard let x = x { ... }
//
guard let image = image else {
print("Image not loaded"); return
}
let size = image.size.scaled(by: 2.0)
//
guard let image = UIImage(named: selectedImageName)
else { preconditionFailure("Missing (selectedImageName)
asset") }
IUO
class Company {
let name: String
var ceo: CEO!
init(name: String, ceoName: String) {
self.name = name
self.ceo = CEO(name: ceoName, company: self)
}
}
class CEO {
let name: String
unowned let company: Company
init(name: String, company: Company) {
self.name = name
self.company = company
}
}
let company = Company(name: "HK", ceoName: "Min")
Enum Associated Value
enum JSONData {
case null
case bool(Bool)
case number(Double)
case string(String)
case array([JSONData])
case object([String: JSONData])
var string: String? {
guard case .string(let s) = self else { return nil }
return s
}
var array: [JSONData]? {
guard case .array(let a) = self else { return nil }
return a
}
var object: [String: JSONData]? {
guard case .object(let o) = self else { return nil }
return o
}
}
case bool(boolValue: Bool)
case number(numberValue: Double)X
Enum Error
enum Error: String, Error {
case invalidFormat = " ."
case quit = " ."
case notFound = " ."
}
enum MenuError: Error {
case invalidFormat
case quit
case notFound
var localizedDescription: String {
switch self {
case .invalidInput:
return " ."
case .quit:
return " ."
case .notFound:
return " ."
}
}
}
✱
✱
✱
Type Casting conditionally
var dict: [AnyHashable: Any] = [:]
dict["age"] = 33
if let anyValue = dict[“age"],
anyValue is Int
{
let intValue = anyValue as! Int
//
}
guard let intValue = dict[“age"] as? Int else { return }
let wrappedValue: AnyHashable? = "value" // typed AnyHashable?
let unwrappedValue: AnyHashable = "value" // typed AnyHashable
let optString1 = unwrappedValue as? String // typed String?
let optString2 = wrappedValue as? String // typed String?
let veryOptyString: String???????????? = optString2 // Typed String????????????
let lessOptyString: String??? = veryOptyString // Error!
Lazy Eveluation
internal init(_ seq1: Sequence1, _ seq2: Sequence2)
let sequence = seq1.lazy.flatMap ({
item1 in seq2.lazy.map ({
item2 in (item1, item2)
})
})
_iterator = sequence.makeIterator()
}
✱
✱ (Eager)
✱ lazily, eagerly
guard vs if-else
static func analyzeJSONData(in value: String) throws -> JSONDataCountable {
if value.isEmpty {
throw JSONError.emptyValue
}
guard value.hasPrefix(JSONDataTypePattern.leftBrace) else {
return try makeJSONArray(in: value)
}
return try makeJSONObject(in: value)
}
static func analyzeJSONData(in value: String) throws -> JSONDataCountable {
guard value.count > 0 else {
throw JSONError.emptyValue
}
if value.hasPrefix(JSONDataTypePattern.leftBrace) {
//
return try makeJSONObject(in: value)
}
return try makeJSONArray(in: value)
}
Trailing Closures
let words = sentence.characters.split(separator: " ")
.filter({ $0.count > 4 })
.map({ String($0) })
let nums: [Int] = arguments
.flatMap({ Int($0, radix:10) })
.flatMap({ $0 > 0 ? $0 : nil })
dispatch(after: maxItem + 1) { semaphore.signal() }
DispatchQueue
.global(qos: .default) .asyncAfter(deadline: delay) {
// ...
}
UIView.animate(withDuration: 0.3) {
// ...
}
for value in items.map({ pow($0, 2) }) {
print(value)
}
//
UIView.animate(withDuration: 2.0,
animations: { v.removeFromSuperview() },
completion: { _ in postNotification() } )
?
?
?
?
?
아냐 너 먼저가...아마.. 쉬울꺼야
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
1. (intent) .
2. else .
3. .
4. .
5. ( )
6. .
7. 2 .
8. .
9. / / .

Software maintenance is
not 'keep it working like before'.
It is 'keep it being useful in a changing world’
- Jessica Kerr

More Related Content

What's hot

Unbreakable: The Craft of Code
Unbreakable: The Craft of CodeUnbreakable: The Craft of Code
Unbreakable: The Craft of CodeJoe Morgan
 
AST Rewriting Using recast and esprima
AST Rewriting Using recast and esprimaAST Rewriting Using recast and esprima
AST Rewriting Using recast and esprimaStephen Vance
 
async/await Revisited
async/await Revisitedasync/await Revisited
async/await RevisitedRiza Fahmi
 
Writing Your App Swiftly
Writing Your App SwiftlyWriting Your App Swiftly
Writing Your App SwiftlySommer Panage
 
Teaching Your Machine To Find Fraudsters
Teaching Your Machine To Find FraudstersTeaching Your Machine To Find Fraudsters
Teaching Your Machine To Find FraudstersIan Barber
 
ES6 patterns in the wild
ES6 patterns in the wildES6 patterns in the wild
ES6 patterns in the wildJoe Morgan
 
Debugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 VersionDebugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 VersionIan Barber
 
AST - the only true tool for building JavaScript
AST - the only true tool for building JavaScriptAST - the only true tool for building JavaScript
AST - the only true tool for building JavaScriptIngvar Stepanyan
 
Essentials and Impactful Features of ES6
Essentials and Impactful Features of ES6Essentials and Impactful Features of ES6
Essentials and Impactful Features of ES6Riza Fahmi
 
Workshop 5: JavaScript testing
Workshop 5: JavaScript testingWorkshop 5: JavaScript testing
Workshop 5: JavaScript testingVisual Engineering
 
Building Real Time Systems on MongoDB Using the Oplog at Stripe
Building Real Time Systems on MongoDB Using the Oplog at StripeBuilding Real Time Systems on MongoDB Using the Oplog at Stripe
Building Real Time Systems on MongoDB Using the Oplog at StripeStripe
 
Building Real Time Systems on MongoDB Using the Oplog at Stripe
Building Real Time Systems on MongoDB Using the Oplog at StripeBuilding Real Time Systems on MongoDB Using the Oplog at Stripe
Building Real Time Systems on MongoDB Using the Oplog at StripeMongoDB
 
How to stand on the shoulders of giants
How to stand on the shoulders of giantsHow to stand on the shoulders of giants
How to stand on the shoulders of giantsIan Barber
 
Writing Clean Code in Swift
Writing Clean Code in SwiftWriting Clean Code in Swift
Writing Clean Code in SwiftDerek Lee Boire
 

What's hot (20)

Unbreakable: The Craft of Code
Unbreakable: The Craft of CodeUnbreakable: The Craft of Code
Unbreakable: The Craft of Code
 
Say It With Javascript
Say It With JavascriptSay It With Javascript
Say It With Javascript
 
AST Rewriting Using recast and esprima
AST Rewriting Using recast and esprimaAST Rewriting Using recast and esprima
AST Rewriting Using recast and esprima
 
"let ECMAScript = 6"
"let ECMAScript = 6" "let ECMAScript = 6"
"let ECMAScript = 6"
 
Your code is not a string
Your code is not a stringYour code is not a string
Your code is not a string
 
async/await Revisited
async/await Revisitedasync/await Revisited
async/await Revisited
 
Writing Your App Swiftly
Writing Your App SwiftlyWriting Your App Swiftly
Writing Your App Swiftly
 
Teaching Your Machine To Find Fraudsters
Teaching Your Machine To Find FraudstersTeaching Your Machine To Find Fraudsters
Teaching Your Machine To Find Fraudsters
 
ES6 patterns in the wild
ES6 patterns in the wildES6 patterns in the wild
ES6 patterns in the wild
 
Debugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 VersionDebugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 Version
 
AST - the only true tool for building JavaScript
AST - the only true tool for building JavaScriptAST - the only true tool for building JavaScript
AST - the only true tool for building JavaScript
 
Essentials and Impactful Features of ES6
Essentials and Impactful Features of ES6Essentials and Impactful Features of ES6
Essentials and Impactful Features of ES6
 
Workshop 5: JavaScript testing
Workshop 5: JavaScript testingWorkshop 5: JavaScript testing
Workshop 5: JavaScript testing
 
Workshop 10: ECMAScript 6
Workshop 10: ECMAScript 6Workshop 10: ECMAScript 6
Workshop 10: ECMAScript 6
 
Building Real Time Systems on MongoDB Using the Oplog at Stripe
Building Real Time Systems on MongoDB Using the Oplog at StripeBuilding Real Time Systems on MongoDB Using the Oplog at Stripe
Building Real Time Systems on MongoDB Using the Oplog at Stripe
 
Building Real Time Systems on MongoDB Using the Oplog at Stripe
Building Real Time Systems on MongoDB Using the Oplog at StripeBuilding Real Time Systems on MongoDB Using the Oplog at Stripe
Building Real Time Systems on MongoDB Using the Oplog at Stripe
 
How to stand on the shoulders of giants
How to stand on the shoulders of giantsHow to stand on the shoulders of giants
How to stand on the shoulders of giants
 
Writing Clean Code in Swift
Writing Clean Code in SwiftWriting Clean Code in Swift
Writing Clean Code in Swift
 
PHP 5.4
PHP 5.4PHP 5.4
PHP 5.4
 
ES6 - Level up your JavaScript Skills
ES6 - Level up your JavaScript SkillsES6 - Level up your JavaScript Skills
ES6 - Level up your JavaScript Skills
 

Similar to 스위프트를 여행하는 히치하이커를 위한 스타일 안내

Idioms in swift 2016 05c
Idioms in swift 2016 05cIdioms in swift 2016 05c
Idioms in swift 2016 05cKaz Yoshikawa
 
What's in Kotlin for us - Alexandre Greschon, MyHeritage
What's in Kotlin for us - Alexandre Greschon, MyHeritageWhat's in Kotlin for us - Alexandre Greschon, MyHeritage
What's in Kotlin for us - Alexandre Greschon, MyHeritageDroidConTLV
 
Security Meetup 22 октября. «PHP Unserialize Exploiting». Павел Топорков. Лаб...
Security Meetup 22 октября. «PHP Unserialize Exploiting». Павел Топорков. Лаб...Security Meetup 22 октября. «PHP Unserialize Exploiting». Павел Топорков. Лаб...
Security Meetup 22 октября. «PHP Unserialize Exploiting». Павел Топорков. Лаб...Mail.ru Group
 
Security Meetup 22 октября. «Реверс-инжиниринг в Enterprise». Алексей Секрето...
Security Meetup 22 октября. «Реверс-инжиниринг в Enterprise». Алексей Секрето...Security Meetup 22 октября. «Реверс-инжиниринг в Enterprise». Алексей Секрето...
Security Meetup 22 октября. «Реверс-инжиниринг в Enterprise». Алексей Секрето...Mail.ru Group
 
Get started with YUI
Get started with YUIGet started with YUI
Get started with YUIAdam Lu
 
ハイブリッド言語Scalaを使う
ハイブリッド言語Scalaを使うハイブリッド言語Scalaを使う
ハイブリッド言語Scalaを使うbpstudy
 
What's New in Swift 4
What's New in Swift 4What's New in Swift 4
What's New in Swift 4Young Hoo Kim
 
Absolute Beginners Guide to Puppet Through Types - PuppetConf 2014
Absolute Beginners Guide to Puppet Through Types - PuppetConf 2014Absolute Beginners Guide to Puppet Through Types - PuppetConf 2014
Absolute Beginners Guide to Puppet Through Types - PuppetConf 2014Puppet
 
Implementing the IO Monad in Scala
Implementing the IO Monad in ScalaImplementing the IO Monad in Scala
Implementing the IO Monad in ScalaHermann Hueck
 
20191116 custom operators in swift
20191116 custom operators in swift20191116 custom operators in swift
20191116 custom operators in swiftChiwon Song
 
Introduction to CQRS and Event Sourcing
Introduction to CQRS and Event SourcingIntroduction to CQRS and Event Sourcing
Introduction to CQRS and Event SourcingSamuel ROZE
 
Soundreader.classpathSoundreader.project Soundre.docx
Soundreader.classpathSoundreader.project  Soundre.docxSoundreader.classpathSoundreader.project  Soundre.docx
Soundreader.classpathSoundreader.project Soundre.docxwhitneyleman54422
 
JavaScript - i och utanför webbläsaren (2010-03-03)
JavaScript - i och utanför webbläsaren (2010-03-03)JavaScript - i och utanför webbläsaren (2010-03-03)
JavaScript - i och utanför webbläsaren (2010-03-03)Anders Jönsson
 
Security Challenges in Node.js
Security Challenges in Node.jsSecurity Challenges in Node.js
Security Challenges in Node.jsWebsecurify
 
Introduction to Kotlin.pptx
Introduction to Kotlin.pptxIntroduction to Kotlin.pptx
Introduction to Kotlin.pptxAzharFauzan9
 
01 Introduction to Kotlin - Programming in Kotlin.pptx
01 Introduction to Kotlin - Programming in Kotlin.pptx01 Introduction to Kotlin - Programming in Kotlin.pptx
01 Introduction to Kotlin - Programming in Kotlin.pptxIvanZawPhyo
 

Similar to 스위프트를 여행하는 히치하이커를 위한 스타일 안내 (20)

Idioms in swift 2016 05c
Idioms in swift 2016 05cIdioms in swift 2016 05c
Idioms in swift 2016 05c
 
What's in Kotlin for us - Alexandre Greschon, MyHeritage
What's in Kotlin for us - Alexandre Greschon, MyHeritageWhat's in Kotlin for us - Alexandre Greschon, MyHeritage
What's in Kotlin for us - Alexandre Greschon, MyHeritage
 
Security Meetup 22 октября. «PHP Unserialize Exploiting». Павел Топорков. Лаб...
Security Meetup 22 октября. «PHP Unserialize Exploiting». Павел Топорков. Лаб...Security Meetup 22 октября. «PHP Unserialize Exploiting». Павел Топорков. Лаб...
Security Meetup 22 октября. «PHP Unserialize Exploiting». Павел Топорков. Лаб...
 
Security Meetup 22 октября. «Реверс-инжиниринг в Enterprise». Алексей Секрето...
Security Meetup 22 октября. «Реверс-инжиниринг в Enterprise». Алексей Секрето...Security Meetup 22 октября. «Реверс-инжиниринг в Enterprise». Алексей Секрето...
Security Meetup 22 октября. «Реверс-инжиниринг в Enterprise». Алексей Секрето...
 
Introduction to kotlin
Introduction to kotlinIntroduction to kotlin
Introduction to kotlin
 
Get started with YUI
Get started with YUIGet started with YUI
Get started with YUI
 
ハイブリッド言語Scalaを使う
ハイブリッド言語Scalaを使うハイブリッド言語Scalaを使う
ハイブリッド言語Scalaを使う
 
What's New in Swift 4
What's New in Swift 4What's New in Swift 4
What's New in Swift 4
 
Absolute Beginners Guide to Puppet Through Types - PuppetConf 2014
Absolute Beginners Guide to Puppet Through Types - PuppetConf 2014Absolute Beginners Guide to Puppet Through Types - PuppetConf 2014
Absolute Beginners Guide to Puppet Through Types - PuppetConf 2014
 
Implementing the IO Monad in Scala
Implementing the IO Monad in ScalaImplementing the IO Monad in Scala
Implementing the IO Monad in Scala
 
20191116 custom operators in swift
20191116 custom operators in swift20191116 custom operators in swift
20191116 custom operators in swift
 
Ruby tricks2
Ruby tricks2Ruby tricks2
Ruby tricks2
 
Introduction to CQRS and Event Sourcing
Introduction to CQRS and Event SourcingIntroduction to CQRS and Event Sourcing
Introduction to CQRS and Event Sourcing
 
Soundreader.classpathSoundreader.project Soundre.docx
Soundreader.classpathSoundreader.project  Soundre.docxSoundreader.classpathSoundreader.project  Soundre.docx
Soundreader.classpathSoundreader.project Soundre.docx
 
Kotlin
KotlinKotlin
Kotlin
 
JavaScript - i och utanför webbläsaren (2010-03-03)
JavaScript - i och utanför webbläsaren (2010-03-03)JavaScript - i och utanför webbläsaren (2010-03-03)
JavaScript - i och utanför webbläsaren (2010-03-03)
 
Security Challenges in Node.js
Security Challenges in Node.jsSecurity Challenges in Node.js
Security Challenges in Node.js
 
Introduction to Kotlin.pptx
Introduction to Kotlin.pptxIntroduction to Kotlin.pptx
Introduction to Kotlin.pptx
 
01 Introduction to Kotlin - Programming in Kotlin.pptx
01 Introduction to Kotlin - Programming in Kotlin.pptx01 Introduction to Kotlin - Programming in Kotlin.pptx
01 Introduction to Kotlin - Programming in Kotlin.pptx
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 

More from Jung Kim

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

More from Jung Kim (13)

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

Recently uploaded

Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxhumanexperienceaaa
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 

Recently uploaded (20)

Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 

스위프트를 여행하는 히치하이커를 위한 스타일 안내

  • 4. ✱ Main - , , , ✱ Reusability - DRY, components, generics ✱ Reliability - Exception handling and cleanup ✱ Extensibility ✱ Security - , , , ✱ Performance - , Lazy Loading, , ✱ Scalability - ✱ Usability -
  • 5. - SOLID 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) .
  • 6. SRP struct InputView { func readInput() { print(" .") let userCoordinate = readLine() guard let input = userCoordinate else { return } print(seperateCoordinates(userInput: input)) } //… } struct InputView { func readInput() -> String { print(" .") let userCoordinate = readLine() guard let input = userCoordinate else { return "" } return input } //… }
  • 7. DI class MessageListViewController: UITableViewController { private let loader: MessageLoader init(loader: MessageLoader) { self.loader = loader super.init(nibName: nil, bundle: nil) } override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) loader.load { [weak self] messages in self?.reloadTableView(with: messages) } } } ✱ ✱ ✱
  • 8. Interface Protocol Segregation protocol MyShape { var resultDescription: String { get } func calculateOfPosition() -> [MyPoint] func resultOfMyShape() -> Double } struct MyLine: MyShape { private(set) var pointA = MyPoint() private(set) var pointB = MyPoint() func calculateOfPosition() -> [MyPoint] { return [pointA, pointB] } func resultOfMyShape() -> Double { return calculateOfLength() } // var resultDescription: String = { return " " }() } struct MyPoint: MyShape { private(set) var x = 0 private(set) var y = 0 func calculateOfPosition() -> [MyPoint] { return [self] } func resultOfMyShape() -> Double { return 0 } var resultDescription: String = { return "" }() } (before)
  • 9. Protocol Segregation (after) protocol MyShape { func calculateOfPosition() -> [MyPoint] func resultOfMyShape() -> Double } protocol MyDescription { var resultDescription: String { get } } struct MyLine: MyShape, MyDescription { private(set) var pointA = MyPoint() private(set) var pointB = MyPoint() func calculateOfPosition() -> [MyPoint] { return [pointA, pointB] } func resultOfMyShape() -> Double { return calculateOfLength() } var resultDescription: String = { return " " }() } struct MyPoint: MyShape { private(set) var x = 0 private(set) var y = 0 func calculateOfPosition() -> [MyPoint] { return [self] } func resultOfMyShape() -> Double { return 0 } }
  • 10. Optional guard let y = x { ... } // let image = UIImage(named: "Background") if image == nil { print("Image not loaded ") return } let size = image!.frame.size.scaled(by: 2.0) // let image = UIImage(named: selectedImageName)! guard let x = x { ... } // guard let image = image else { print("Image not loaded"); return } let size = image.size.scaled(by: 2.0) // guard let image = UIImage(named: selectedImageName) else { preconditionFailure("Missing (selectedImageName) asset") }
  • 11. IUO class Company { let name: String var ceo: CEO! init(name: String, ceoName: String) { self.name = name self.ceo = CEO(name: ceoName, company: self) } } class CEO { let name: String unowned let company: Company init(name: String, company: Company) { self.name = name self.company = company } } let company = Company(name: "HK", ceoName: "Min")
  • 12. Enum Associated Value enum JSONData { case null case bool(Bool) case number(Double) case string(String) case array([JSONData]) case object([String: JSONData]) var string: String? { guard case .string(let s) = self else { return nil } return s } var array: [JSONData]? { guard case .array(let a) = self else { return nil } return a } var object: [String: JSONData]? { guard case .object(let o) = self else { return nil } return o } } case bool(boolValue: Bool) case number(numberValue: Double)X
  • 13. Enum Error enum Error: String, Error { case invalidFormat = " ." case quit = " ." case notFound = " ." } enum MenuError: Error { case invalidFormat case quit case notFound var localizedDescription: String { switch self { case .invalidInput: return " ." case .quit: return " ." case .notFound: return " ." } } } ✱ ✱ ✱
  • 14. Type Casting conditionally var dict: [AnyHashable: Any] = [:] dict["age"] = 33 if let anyValue = dict[“age"], anyValue is Int { let intValue = anyValue as! Int // } guard let intValue = dict[“age"] as? Int else { return } let wrappedValue: AnyHashable? = "value" // typed AnyHashable? let unwrappedValue: AnyHashable = "value" // typed AnyHashable let optString1 = unwrappedValue as? String // typed String? let optString2 = wrappedValue as? String // typed String? let veryOptyString: String???????????? = optString2 // Typed String???????????? let lessOptyString: String??? = veryOptyString // Error!
  • 15. Lazy Eveluation internal init(_ seq1: Sequence1, _ seq2: Sequence2) let sequence = seq1.lazy.flatMap ({ item1 in seq2.lazy.map ({ item2 in (item1, item2) }) }) _iterator = sequence.makeIterator() } ✱ ✱ (Eager) ✱ lazily, eagerly
  • 16. guard vs if-else static func analyzeJSONData(in value: String) throws -> JSONDataCountable { if value.isEmpty { throw JSONError.emptyValue } guard value.hasPrefix(JSONDataTypePattern.leftBrace) else { return try makeJSONArray(in: value) } return try makeJSONObject(in: value) } static func analyzeJSONData(in value: String) throws -> JSONDataCountable { guard value.count > 0 else { throw JSONError.emptyValue } if value.hasPrefix(JSONDataTypePattern.leftBrace) { // return try makeJSONObject(in: value) } return try makeJSONArray(in: value) }
  • 17. Trailing Closures let words = sentence.characters.split(separator: " ") .filter({ $0.count > 4 }) .map({ String($0) }) let nums: [Int] = arguments .flatMap({ Int($0, radix:10) }) .flatMap({ $0 > 0 ? $0 : nil }) dispatch(after: maxItem + 1) { semaphore.signal() } DispatchQueue .global(qos: .default) .asyncAfter(deadline: delay) { // ... } UIView.animate(withDuration: 0.3) { // ... } for value in items.map({ pow($0, 2) }) { print(value) } // UIView.animate(withDuration: 2.0, animations: { v.removeFromSuperview() }, completion: { _ in postNotification() } )
  • 19. 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
  • 20. 1. (intent) . 2. else . 3. . 4. . 5. ( ) 6. . 7. 2 . 8. . 9. / / .
  • 21.
  • 22.  Software maintenance is not 'keep it working like before'. It is 'keep it being useful in a changing world’ - Jessica Kerr