SlideShare a Scribd company logo
Design Patterns in Ruby
By Anup Biswal
Agenda
● Goal of the talk
● Design Patterns WHAT, WHY
● Dynamic nature of Ruby
● Various patterns with examples and use
cases
WHAT
General reusable solution to a commonly
occurring problem
WHY
mcioffeae ?????
Ruby is dynamic
What do you mean?
Quiz
Some of the patterns we always use?
HOW
● Creational
● Structural
● Behavioural
Creational
● Builder
● Factory
● Singleton
Builder
The purpose of the Builder Pattern is to create an abstract blueprint describing
the steps of creating an object, and then allow many different implementations
to actually carry out that process as long as they provide the necessary steps
Factory
The Factory Method Pattern is used for putting a layer of abstraction on top of
object creation so that directly working with its constructor is no longer
necessary. This process can lead to more expressive ways of building new
objects, and can also allow for the creation of new objects without explicitly
referencing their class.
Singleton
The Singleton pattern is used in situations where a single instance of a class is
all you need. Singleton objects are meant provide an effective way of organizing
global state and behavior, such as configuration data, logging support, or other
similar needs
Structural
● Adapter
● Decorator
● Proxy
Decorator
While there is a more clear distinction between a Decorator and a Proxy in
static languages, in Ruby the two concepts almost merge, except that a
Decorator is used almost exclusively for the purpose of adding / extending
behavior of a target object, and a Proxy is a more general concept
Adapter
An Adapter is used when you want to provide a unified interface to a number of
different objects that implement similar functionality
Proxy
A Proxy is any object that acts as a drop-in replacement object that does a bit of
work and then delegates to some other underlying object
Behavioural
● Command
● Strategy
● Observer
Command
The command pattern is a behavior design pattern used to store the
information necessary to call methods at a future time.
Strategy
The basic idea is to delegate tasks to encapsulated algorithms which are
interchangable at runtime.
Observer
The observer pattern is for event driven programming.
An object, called the subject, maintains a list of its dependents, called
observers, and notifies them automatically of any state changes, usually by
calling one of their methods.

More Related Content

PDF
Null object pattern
PDF
Why should a Java programmer shifts towards Functional Programming Paradigm
PDF
Functional Programming in Ruby
PDF
Angular directives and pipes
PPTX
Generator patterns
PDF
Rapid and repeatable geospatial analysis with Python and JavaScript using not...
PPTX
The Bleeding Edge - Whats New in Angular 2
PPTX
What is dev ops?
Null object pattern
Why should a Java programmer shifts towards Functional Programming Paradigm
Functional Programming in Ruby
Angular directives and pipes
Generator patterns
Rapid and repeatable geospatial analysis with Python and JavaScript using not...
The Bleeding Edge - Whats New in Angular 2
What is dev ops?

What's hot (13)

PPTX
Dynamic content with Angular
PDF
Introduction to Higher Order Functions in Scala
PDF
Thinking Functionally
PDF
Collaborative environment with data science notebook
PPTX
JavaScript (without DOM)
PDF
Collaborative data science and how to build a data science toolchain around n...
PDF
Kotlin & arrow: the functional way
PPTX
PPTX
PPTX
PDF
PDF
FRP with Ractive and RxJS
PDF
Kotlin & Arrow the functional way
Dynamic content with Angular
Introduction to Higher Order Functions in Scala
Thinking Functionally
Collaborative environment with data science notebook
JavaScript (without DOM)
Collaborative data science and how to build a data science toolchain around n...
Kotlin & arrow: the functional way
FRP with Ractive and RxJS
Kotlin & Arrow the functional way
Ad

Viewers also liked (9)

PDF
Design Pattern From Java To Ruby
PDF
エクストリームエンジニア1
PDF
Basic Rails Training
ODP
デザインパターン(初歩的な7パターン)
ODP
Strategy パターンと開放/閉鎖原則に見るデザインパターンの有用性
PPT
Firefox-Addons
PDF
The way to the timeless way of programming
PPT
Metaprogramming With Ruby
PDF
Functional Ruby
Design Pattern From Java To Ruby
エクストリームエンジニア1
Basic Rails Training
デザインパターン(初歩的な7パターン)
Strategy パターンと開放/閉鎖原則に見るデザインパターンの有用性
Firefox-Addons
The way to the timeless way of programming
Metaprogramming With Ruby
Functional Ruby
Ad

Similar to Design Patterns in Ruby (20)

PDF
Design patterns for fun & profit - CoderCruise 2018
PDF
Towards More Flexible Enterprise Information Systems
PPTX
Design Patterns In Scala
ODP
Design Patterns Part1
PPTX
Software design and Architecture.pptx
PPTX
Segue to design patterns
PDF
Introduction to Domain driven design
PPTX
OOP design patterns
PPTX
Gof design patterns
PPTX
Object Oriented, Design patterns and data modelling worshop
PPTX
UNIT IV DESIGN PATTERNS.pptx
PDF
Unified Modeling Language (UML), Object-Oriented Programming Concepts & Desig...
ODP
Design Patterns
PDF
Design patterns in javascript
PDF
Gof design pattern
PDF
Benefits of using software design patterns and when to use design pattern
PDF
Agile cards
PDF
GOF Design pattern with java
PPT
Object-Oriented Analysis and Design
PPT
Software Design Patterns
Design patterns for fun & profit - CoderCruise 2018
Towards More Flexible Enterprise Information Systems
Design Patterns In Scala
Design Patterns Part1
Software design and Architecture.pptx
Segue to design patterns
Introduction to Domain driven design
OOP design patterns
Gof design patterns
Object Oriented, Design patterns and data modelling worshop
UNIT IV DESIGN PATTERNS.pptx
Unified Modeling Language (UML), Object-Oriented Programming Concepts & Desig...
Design Patterns
Design patterns in javascript
Gof design pattern
Benefits of using software design patterns and when to use design pattern
Agile cards
GOF Design pattern with java
Object-Oriented Analysis and Design
Software Design Patterns

More from Mindfire Solutions (20)

PDF
Physician Search and Review
PDF
diet management app
PDF
Business Technology Solution
PDF
Remote Health Monitoring
PDF
Influencer Marketing Solution
PPT
High Availability of Azure Applications
PPTX
IOT Hands On
PPTX
Glimpse of Loops Vs Set
ODP
Oracle Sql Developer-Getting Started
PPT
Adaptive Layout In iOS 8
PPT
Introduction to Auto-layout : iOS/Mac
PPT
LINQPad - utility Tool
PPT
Get started with watch kit development
PPTX
Swift vs Objective-C
ODP
Material Design in Android
ODP
Introduction to OData
PPT
Ext js Part 2- MVC
PPT
ExtJs Basic Part-1
PPT
Spring Security Introduction
Physician Search and Review
diet management app
Business Technology Solution
Remote Health Monitoring
Influencer Marketing Solution
High Availability of Azure Applications
IOT Hands On
Glimpse of Loops Vs Set
Oracle Sql Developer-Getting Started
Adaptive Layout In iOS 8
Introduction to Auto-layout : iOS/Mac
LINQPad - utility Tool
Get started with watch kit development
Swift vs Objective-C
Material Design in Android
Introduction to OData
Ext js Part 2- MVC
ExtJs Basic Part-1
Spring Security Introduction

Recently uploaded (20)

PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
System and Network Administration Chapter 2
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PPTX
Introduction to Artificial Intelligence
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PPTX
ai tools demonstartion for schools and inter college
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Nekopoi APK 2025 free lastest update
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
Transform Your Business with a Software ERP System
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Operating system designcfffgfgggggggvggggggggg
System and Network Administration Chapter 2
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
wealthsignaloriginal-com-DS-text-... (1).pdf
Introduction to Artificial Intelligence
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
CHAPTER 2 - PM Management and IT Context
Navsoft: AI-Powered Business Solutions & Custom Software Development
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
ai tools demonstartion for schools and inter college
Upgrade and Innovation Strategies for SAP ERP Customers
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PTS Company Brochure 2025 (1).pdf.......
Nekopoi APK 2025 free lastest update
Softaken Excel to vCard Converter Software.pdf
Transform Your Business with a Software ERP System
Lecture 3: Operating Systems Introduction to Computer Hardware Systems

Design Patterns in Ruby