Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Design Patterns
Search
Otemuyiwa Prosper
August 13, 2017
Programming
5
280
Design Patterns
Otemuyiwa Prosper
August 13, 2017
Tweet
Share
More Decks by Otemuyiwa Prosper
See All by Otemuyiwa Prosper
A.I (Artificial Intelligence) for the rest of us
unicodeveloper
2
530
The Complete Guide to building In-App Notifications in Web Apps
unicodeveloper
0
300
The Golden Ticket: Becoming a Superstar & Impactful Open Source Contributor
unicodeveloper
0
130
Optimizing Developer Workflow with Sourcegraph
unicodeveloper
0
170
Code Search with Laravel and Sourcegraph
unicodeveloper
1
300
Lightning Talk - JAMStack
unicodeveloper
0
720
Engineering Faster Web Experiences in Plain Sight
unicodeveloper
0
220
Authentication & Authorization in GraphQL
unicodeveloper
5
2k
Authentication & Authorization in Next.js
unicodeveloper
3
790
Other Decks in Programming
See All in Programming
Conform を推す - Advocating for Conform
mizoguchicoji
3
680
sappoRo.R #12 初心者セッション
kosugitti
0
230
動作確認やテストで漏れがちな観点3選
starfish719
6
1k
Bedrock Agentsレスポンス解析によるAgentのOps
licux
2
720
CNCF Project の作者が考えている OSS の運営
utam0k
5
690
Honoのおもしろいミドルウェアをみてみよう
yusukebe
1
200
“あなた” の開発を支援する AI エージェント Bedrock Engineer / introducing-bedrock-engineer
gawa
11
1.8k
iOSエンジニアから始める visionOS アプリ開発
nao_randd
3
120
DevinとCursorから学ぶAIエージェントメモリーの設計とMoatの考え方
itarutomy
1
640
プログラミング言語学習のススメ / why-do-i-learn-programming-language
yashi8484
0
120
[JAWS-UG横浜 #79] re:Invent 2024 の DB アップデートは Multi-Region!
maroon1st
1
140
Kanzawa.rbのLT大会を支える技術の裏側を変更する Ruby on Rails + Litestream 編
muryoimpl
0
220
Featured
See All Featured
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.6k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
12
950
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
Testing 201, or: Great Expectations
jmmastey
41
7.2k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.2k
Producing Creativity
orderedlist
PRO
343
39k
Fireside Chat
paigeccino
34
3.2k
Optimising Largest Contentful Paint
csswizardry
34
3.1k
Gamification - CAS2011
davidbonilla
80
5.1k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Docker and Python
trallard
44
3.3k
Transcript
Design Patterns Ruby Conf. Nigeria
❖ Software Developer ❖ Consultant at Auth0 ❖ Open Sourcerer
❖ Self-Acclaimed Developer Evangelist ❖ Community Builder ❖ Jollof Rice Ambassador ❖ Google Developer Expert ❖ Homeless Man
@unicodeveloper - GitHub - Twitter
...When no design pattern is involved.
None
...After you involve design patterns.
None
..A few things to note, thou developer
1. Design patterns are not a silver bullet to all
your problems.
2. Design patterns was made for man, not man for
design patterns.
3. They can prove to be a savior, or else
they can make you & your code a mess.
Design Patterns Grouped 1 2 ❖ Behavioral ❖ Creational ❖
Structural
Behavioral Design Patterns 1 3 ❖ Mediator ❖ Observer ❖
Strategy ❖ Visitor ❖ Iterator ❖ Command
Creational Design Patterns 1 4 ❖ Builder ❖ Prototype ❖
Singleton ❖ Factory ❖ Abstract Factory
Structural Design Patterns 1 5 ❖ Facade ❖ Composite ❖
Decorator ❖ Flyweight ❖ Adapter ❖ Bridge
..Know JavaScript? I’ll use it as an example to explain
the common design patterns that you should know & take advantage of in your codebase.
Singleton Pattern
Goals 1. Ensure that only one instance of a class
is created. 2. Provide a global point of access to the object.
Singleton 1 9
Singleton 2 0 What makes the Singleton is the global
access to the instance.
Prototype Pattern
Goals 1. Specify the kind of objects to create using
prototypical instance. 2. Create new objects by copying this prototype
Prototype 2 3
Prototype 2 4
Command Pattern
Goals 1. Encapsulate the request in an object 2. Allow
the parameterization of clients with different requests.
Command 2 7
Command 2 8 What if the core API of carManager
changed? What happens?
Facade Pattern
Goals 1. Outward appearance to the world which hides a
different reality. 2. Simpler public interface to avoid calling many internal methods to get some behavior working. 3. Ability to directly interact with subsystems in a way that can be less prone to accessing it directly.
Facade 3 1
Facade 3 2 JQuery’s document.ready() function is being powered by
bindReady()
Factory Pattern
Goals 1. Creates objects without exposing the instantiation logic to
the client. 2. Refer to newly created object through a common interface.
Factory 3 5
Factory 3 6
The Mixin Pattern
Goals 1. Allow objects to borrow functionality with a minimal
amount of complexity.
Mixin 3 9
Mixin 4 0
Decorator Pattern
Goals 1. Similar to Mixins. Aim to promote code reuse
2. Offer ability to add behaviour to existing classes in a system dynamically.
Decorator 4 3 Simple Use case
Decorator 4 4
Decorator 4 5 Decorating objects with multiple decorators
Module Pattern
Goals 1. Emulate the concept of classes. 2. Shield particular
parts from global scope and make everything simple.
Module 4 8
Module 4 9
Observer Pattern
Goals 1. Define a one to many dependency between objects
so that when one object changes state, all its dependents are notified and updated automatically.
Observer 5 2
Observer 5 3
Observer 5 4
Observer 5 5
Observer 5 6
Observer 5 7
Learning Resource http://www.oodesign.com/observer-pattern.html https://addyosmani.com/resources/essentialjsdes ignpatterns/book/
Thank You!