SlideShare a Scribd company logo
Design Patterns
in Swift
Ch 0 Introduction
Sai Li @ Yowoo Tech.
2017/3/17
Agenda
• Prologue
• What is Pattern?
• OOP Recap
2
• After OOP
• Clean Code, OOP, Design Pattern,
Refactor, Platform Framework, Test
• Future interview
3
know nothing
work
What is a Pattern?
Christopher Alexander (1936 - )
Each pattern is a three-part rule, which
expresses a relation between a certain
context, a problem, and a solution.
Christopher Alexander (1979, p. 247)
Pattern is a solution to a
problem in a context
• Context: A CEO of a company
• Problem: tough competition among the 

delivery services, all restaurants were closed by
other company. How to make users order other
food?
• Solution: 8 + 9 = 17
Pattern is a solution to a
recurring problem in a context
• Context: A CEO of a company
• Problem: tough competition among the 

delivery services. How to get more orders?
• Solution: Binding card then ordering for free.
Threaten to selling card information and shut
down server.
Pattern is a proven solution to a
recurring problem in a context
• Context: A CEO of a company
• Problem: tough competition among the 

delivery services. How to get more orders?
• Solution: Send coupons, hold activities. Buy
UberEATs, FoodPanda…
Pattern is a proven solution to a
recurring problem in a 

specific context
• Context: tough competition among the 

delivery services. A CEO of a company with
limited budget
• Problem: How to get more orders?
• Solution: Send coupons, hold activities …
Pattern is a proven solution 

to a recurring problem 

in a specific context
Each pattern describes a problem that occurs over
and over again in our environment, and then
describes the core of the solution to that problem,
in such a way that you can use this solution a
million times over, without ever doing it the same
way twice.
— Christopher Alexander
16
17
• Name
• Context
• Problem
• Solution
• Force
• Resulting Context
Context
Problem
Elements of Pattern
Solution(Form)
Force
Why learn Design Patterns?
• Common ground for communication
• Not for excluding outsiders
•
• Reusable is so hard
• Standing on the shoulders of giants - Issac Newton
18
Design Patterns in Swift ch0 Introduction
20
Erich Gamma,
Richard Helm,
Ralph Johnson,
John Vlissides
Gang of Four (GoF)
1994 ~
References


by Teddy Chen
21
• Purpose
1. Creational
2. Structural
3. Behavioral

22
• Scope
1. Class: static
2. Object: dynamic

purpose
creational structural behavioral
scope
class Factory Method Adaptor
Interpreter
Template Method
object
Abstract Factory
Builder
Prototype
Singleton
Adapter
Bridge
Composite
Decorator
Facade
Flyweight
Proxy
Chain of Responsibility
Command
Iterator
Mediator
Memento
Observer
State
Strategy
Visitor
How to learn Design Patterns?
• Joshua Kerievsky : A Learning Guide to Design
Patterns

• One more time
24
message (request)
method (operation) encapsulation
signature (name, parameters, return type)
• Design: Abstraction
• Flow & Algorithms: Strategy
• State: State
• type: a specific interface
Dynamic Binding
Polymorphism
Design Patterns in Swift ch0 Introduction
Program to an interface, 

not an implementation
• Clients remain unaware of the specific types or class
• Clients only know about the abstract class defining the
interface.
Inheritance vs. Composition
• White box & Black Box
• Compile time & Runtime
30
Favor object composition over class inheritance
Delegate
32
• Class composition
• Class inheritance
• Parameterized type (Generic, Template)

Array<String>()
Reuse
aggregation
acquaintance

(association, using)
has-A (part of)
using (know of)
Toolkit
vs.
Framework
References
•
• https://s-media-cache-ak0.pinimg.com/736x/8d/dc/a5/8ddca508d43902192028cc0f0f1ad763.jpg
• https://upload.wikimedia.org/wikipedia/en/b/bf/The_Timeless_Way_of_Building.jpg
• https://d2hsbzg80yxel6.cloudfront.net/images/85778/original/9572054112.jpg
• https://images-na.ssl-images-amazon.com/images/I/81r69ARQevL.jpg
• https://d2hsbzg80yxel6.cloudfront.net/images/49583/original/9789866761799.jpg
• https://images-na.ssl-images-amazon.com/images/I/41Uat
%2B4bqAL._SX258_BO1,204,203,200_.jpg
36

More Related Content

PPSX
Homepage i TOS - #Moja Srbija
PDF
Scrumban
PDF
Mastering composer
PPTX
Android tv market - March 2017 - analysis and commentary
PDF
Scrum & Kanban Introduction
PDF
How to Become a Better Scrum Master - Agile Tour Beirut 2016 - Ben Linders
PDF
Keynote Need for Continuous Improvement - Agile Tour Kaunas 2016 - Ben Linders
PDF
Oefeningen voor waardevolle agile retrospectives - Agile Hub Noord 2016 - Ben...
Homepage i TOS - #Moja Srbija
Scrumban
Mastering composer
Android tv market - March 2017 - analysis and commentary
Scrum & Kanban Introduction
How to Become a Better Scrum Master - Agile Tour Beirut 2016 - Ben Linders
Keynote Need for Continuous Improvement - Agile Tour Kaunas 2016 - Ben Linders
Oefeningen voor waardevolle agile retrospectives - Agile Hub Noord 2016 - Ben...

Viewers also liked (15)

PDF
Spicing up Agile Retrospectives - Agile Practitioners 2016 - Ben Linders
PDF
Getting Business Value out of Agile Retrospectives - ITMPI 2014 - Ben Linders
PDF
Doing Valuable Agile Retrospectives -ATBru 2014 - Ben Linders
PDF
Change agile for XP Days 2012 benelux v1.0
PDF
Valuable Agile Retrospectives - QA&Test 2014 - Ben Linders
PDF
The Business Benefit of Root Cause Analysis, Ben Linders, SM/ASM Conference 2003
PDF
Need for Continuous Improvement in Agile -Keynote 1stconf Melbourne 2016 - Be...
PDF
Reaching Business Goals with Value Adding CMMI Assessments, Ben Linders, Euro...
PDF
Controlling Project during Development with a Defect Model, Ben Linders, ICST...
PDF
Real Agile Value with Agile Retrospectives - The making of...
PDF
Scene setting: Recent trends in Process Improvement
PPT
Change Using your Strengths: That's a change!
PDF
Controlling Project Performance by Using a Defect Model - SEPG NA 2008 - Ben ...
PDF
Controlling Project during Development with a Defect Model, Ben Linders, Euro...
PDF
Sustainable Improvement through Agile Retrospectives - AgileEE 2015 - Ben Li...
Spicing up Agile Retrospectives - Agile Practitioners 2016 - Ben Linders
Getting Business Value out of Agile Retrospectives - ITMPI 2014 - Ben Linders
Doing Valuable Agile Retrospectives -ATBru 2014 - Ben Linders
Change agile for XP Days 2012 benelux v1.0
Valuable Agile Retrospectives - QA&Test 2014 - Ben Linders
The Business Benefit of Root Cause Analysis, Ben Linders, SM/ASM Conference 2003
Need for Continuous Improvement in Agile -Keynote 1stconf Melbourne 2016 - Be...
Reaching Business Goals with Value Adding CMMI Assessments, Ben Linders, Euro...
Controlling Project during Development with a Defect Model, Ben Linders, ICST...
Real Agile Value with Agile Retrospectives - The making of...
Scene setting: Recent trends in Process Improvement
Change Using your Strengths: That's a change!
Controlling Project Performance by Using a Defect Model - SEPG NA 2008 - Ben ...
Controlling Project during Development with a Defect Model, Ben Linders, Euro...
Sustainable Improvement through Agile Retrospectives - AgileEE 2015 - Ben Li...
Ad

Similar to Design Patterns in Swift ch0 Introduction (20)

PPTX
Design patterns in Object oriented analysis and design
PDF
Design patterns
PPT
Design Pattern
PPTX
Cs 1023 lec 9 design pattern (week 2)
PPT
test download file iehle-Zullighoven-p235.ppt
PPT
Design patterns
PDF
Module 2 design patterns-2
PPT
Design Patterns.ppt
PPT
Design Patterns
PPTX
Design patterns
PDF
Introduction to Design Patterns
PDF
Introduction to Design Pattern
PPT
CS6201 Software Reuse - Design Patterns
PPT
Introduction to Patterns (miniPLoP@Taipei)
DOCX
Unit iii design patterns 9
PPT
Introduction to design patterns
PPT
Design pattern & categories
PPT
6 Design Pattern.ppt design pattern in softeare engineering
PPTX
Software Patterns
PPTX
Python: Design Patterns
Design patterns in Object oriented analysis and design
Design patterns
Design Pattern
Cs 1023 lec 9 design pattern (week 2)
test download file iehle-Zullighoven-p235.ppt
Design patterns
Module 2 design patterns-2
Design Patterns.ppt
Design Patterns
Design patterns
Introduction to Design Patterns
Introduction to Design Pattern
CS6201 Software Reuse - Design Patterns
Introduction to Patterns (miniPLoP@Taipei)
Unit iii design patterns 9
Introduction to design patterns
Design pattern & categories
6 Design Pattern.ppt design pattern in softeare engineering
Software Patterns
Python: Design Patterns
Ad

More from Chihyang Li (20)

PDF
Image Style Transfer and AI on iOS Mobile App
PDF
Image style transfer and iOS CoreML, Vision Frameworks
PDF
Machine Learning in Swift
PDF
Image style transfer & AI on App
PDF
iOS Vision framework
PDF
Design Patterns in Swift Ch5 Abstract Factory Builder
PDF
Design patterns in Swift Ch4: Iterator & Template Method
PDF
Swift map & flatMap
PDF
Swift Optional ??
PDF
Design Pattern in Swift Ch2 Strategy, Decorator
PDF
Design Pattern Ch3 in Swift Composite
PDF
Design Patterns in Swift Ch1 Factory Method
PDF
Object Oriented Programming Ch3 SRP, DIP, ISP
PDF
Object Oriented Programming in Swift Ch2 Polymorphism, OCP, LSP
PDF
Object Oriented Programming in Swift Ch1 - Inheritance
PDF
Object Oriented Programming in Swift Ch0 - Encapsulation
PDF
Apple Swift API Design Guideline
PDF
Swift capture
PDF
DevOps 2016 summit
PDF
Slack introduction
Image Style Transfer and AI on iOS Mobile App
Image style transfer and iOS CoreML, Vision Frameworks
Machine Learning in Swift
Image style transfer & AI on App
iOS Vision framework
Design Patterns in Swift Ch5 Abstract Factory Builder
Design patterns in Swift Ch4: Iterator & Template Method
Swift map & flatMap
Swift Optional ??
Design Pattern in Swift Ch2 Strategy, Decorator
Design Pattern Ch3 in Swift Composite
Design Patterns in Swift Ch1 Factory Method
Object Oriented Programming Ch3 SRP, DIP, ISP
Object Oriented Programming in Swift Ch2 Polymorphism, OCP, LSP
Object Oriented Programming in Swift Ch1 - Inheritance
Object Oriented Programming in Swift Ch0 - Encapsulation
Apple Swift API Design Guideline
Swift capture
DevOps 2016 summit
Slack introduction

Recently uploaded (20)

PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PPTX
Transform Your Business with a Software ERP System
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Transform Your Business with a Software ERP System
Operating system designcfffgfgggggggvggggggggg
2025 Textile ERP Trends: SAP, Odoo & Oracle
wealthsignaloriginal-com-DS-text-... (1).pdf
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
VVF-Customer-Presentation2025-Ver1.9.pptx
Wondershare Filmora 15 Crack With Activation Key [2025
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
How to Migrate SBCGlobal Email to Yahoo Easily
Design an Analysis of Algorithms II-SECS-1021-03
Design an Analysis of Algorithms I-SECS-1021-03
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Navsoft: AI-Powered Business Solutions & Custom Software Development
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
How to Choose the Right IT Partner for Your Business in Malaysia
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025

Design Patterns in Swift ch0 Introduction