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

Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Arindam Chakraborty, Ph.D., P.E. (CA, TX)
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueBhangaleSonal
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapRishantSharmaFr
 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfRagavanV2
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756dollysharma2066
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptNANDHAKUMARA10
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...Call Girls in Nagpur High Profile
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01KreezheaRecto
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxJuliansyahHarahap1
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoordharasingh5698
 

Recently uploaded (20)

Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdf
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
 

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

  • 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