SlideShare a Scribd company logo
Presented By: Vidisha Gupta (Software Consultant @ Knoldus)
Design Patterns
In Scala
Agenda
01 What are Design Patterns?
02
Why do we need design
patterns?
03 Categories of design
patterns
04 Scala Specific Design
Patterns
Demo
60
6
0404
0
5
What are Design Patterns?
Design pattern is a general reusable
solution to a commonly occurring
problem in software design within a
given context.
Design patterns are formalized best
practices that the programmer can
use to solve common problems when
designing an application or system.
Example -
Interface Printer{
void print(String text);
}
Class InkjetPrinter implements Printer {
void print(String text){
// spray ink to the paper, roll the paper etc.
}
}
Printer ticketPrinter = new InkjetPrinter();
Printer ticketPrinter = PrinterFactory.createPrinter("Laser");
What do we need design patterns?
● Scalable
● Stable
● Highly cohesive modules
● Minimal coupling
● Communication between
designers more efficient
● Give the developer a selection
of tried and tested solutions to
work with
● Language neutral
Categories of Design Patterns
Creational Design Pattern
The creational patterns aim to separate a system from how its
objects are created, composed, and represented. They increase
the system's flexibility in terms of the what, who, how, and when of
object creation.
The main ideas behind the creational design patterns are as
follows:
● Knowledge encapsulation about the concrete classes
● Hiding details about the actual creation and how objects are
combined
Structural Design Pattern
Design patterns that ease the design by identifying a simple
way to realize relationships among entities.
The main features of structural design patterns include the
following:
● The use of composition to combine the implementations of
multiple objects
● Help build a large system made of various components by
maintaining a high level of flexibility
Behavioral Design Pattern
Design patterns that identify common communication patterns
among objects and realize these patterns.
The main features of behavioral design patterns are as follows:
● What is being described is a process or flow
● The flows are simplified and made understandable
● They accomplish tasks that would be difficult or impossible to
achieve with objects
Scala Specific Design Patterns
● The Lens Pattern
● Duck Typing
● Memoization
● Pimp Library
● Stackable Traits
● The cake pattern
● Lazy evaluation
● The type class design pattern
● Partial functions
● Implicit Injection
The Lens Pattern
A Lens is an abstraction from
functional programming which
helps to deal with a problem of
updating complex immutable
nested objects.
Available implementations
There are several implementations in scala:
● scalaz.Lens - if you already have scalaz in a project and
you are not bothered to write some code in order to define
lens
● Quicklens - easy to use and powerful enough to deal with
the described problem
● Sauron - very similar to Quicklens and has a less size but
also has less functionality
● Monocle - a powerful library which can help if there is
necessity to use lots of lens in a code.
Duck Typing
● Duck Typing is a way of
programming in which an object
passed into a function or method
supports all method signatures
and attributes expected of that
object at run time.
● It allows developers to write
code that requires the callers to
have some specific methods (but
not implement an interface)
Pimp my Library
● It provides a way to write
extension methods for libraries,
which we cannot modify.
● It also helps to achieve better
code readability.
● Less boiler plate code than
adhoc version
Stackable Traits
● Stackable traits is the Scala way to
implement the decorator design
pattern.
● It involves decoration for the
purpose of class composition
instead of object composition.
● Stackable traits decorate the core
traits at compile time, similar to the
way decorator objects modify core
objects at run time in the decorator
pattern.
Memoization
Memoization is an optimization
technique of caching the output of
an expensive function for a
particular input and then returning
the cached result if the function is
called again with the same input
parameters.
References
● https://github.com/nikolovivan/scala-design-
patterns/tree/master/functional-design-patterns
● https://learning.oreilly.com/library/view/scala-design-
patterns/9781788471305/341918fe-9b85-4246-b062-
a17e9fa17b38.xhtml
Thank You !

More Related Content

What's hot

Fly Weight Design Pattern.pptx
Fly Weight Design Pattern.pptxFly Weight Design Pattern.pptx
Fly Weight Design Pattern.pptx
Saifullah568810
 
Software Design Patterns
Software Design PatternsSoftware Design Patterns
Software Design Patterns
Satheesh Sukumaran
 
Clean architecture
Clean architectureClean architecture
Clean architecture
.NET Crowd
 
Design patterns
Design patternsDesign patterns
Design patterns
abhisheksagi
 
Dependency Injection in iOS
Dependency Injection in iOSDependency Injection in iOS
Dependency Injection in iOS
Pablo Villar
 
Single Responsibility Principle
Single Responsibility PrincipleSingle Responsibility Principle
Single Responsibility Principle
Eyal Golan
 
Design patterns ppt
Design patterns pptDesign patterns ppt
Design patterns ppt
Aman Jain
 
Decorator Pattern
Decorator PatternDecorator Pattern
Decorator Pattern
Dimuthu Anuraj
 
Object-Oriented Design Heuristics
Object-Oriented Design HeuristicsObject-Oriented Design Heuristics
Object-Oriented Design Heuristics
kim.mens
 
Clean architecture
Clean architectureClean architecture
Clean architecture
andbed
 
Bridge Design Pattern
Bridge Design PatternBridge Design Pattern
Bridge Design Pattern
Shahriar Hyder
 
Sqlite
SqliteSqlite
Sqlite
Kumar
 
Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design Pattern
Shahriar Iqbal Chowdhury
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
Anuja Arosha
 
Software Architecture and Design
Software Architecture and DesignSoftware Architecture and Design
Software Architecture and Design
Ra'Fat Al-Msie'deen
 
Domain Driven Design Introduction
Domain Driven Design IntroductionDomain Driven Design Introduction
Domain Driven Design Introduction
wojtek_s
 
Ch9-Software Engineering 9
Ch9-Software Engineering 9Ch9-Software Engineering 9
Ch9-Software Engineering 9
Ian Sommerville
 
Dependency injection presentation
Dependency injection presentationDependency injection presentation
Dependency injection presentation
Ahasanul Kalam Akib
 
Jedi slides 2.1 object-oriented concepts
Jedi slides 2.1 object-oriented conceptsJedi slides 2.1 object-oriented concepts
Jedi slides 2.1 object-oriented concepts
Maryo Manjaruni
 
Project management 02112009
Project management 02112009Project management 02112009
Project management 02112009
Manish Chaurasia
 

What's hot (20)

Fly Weight Design Pattern.pptx
Fly Weight Design Pattern.pptxFly Weight Design Pattern.pptx
Fly Weight Design Pattern.pptx
 
Software Design Patterns
Software Design PatternsSoftware Design Patterns
Software Design Patterns
 
Clean architecture
Clean architectureClean architecture
Clean architecture
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Dependency Injection in iOS
Dependency Injection in iOSDependency Injection in iOS
Dependency Injection in iOS
 
Single Responsibility Principle
Single Responsibility PrincipleSingle Responsibility Principle
Single Responsibility Principle
 
Design patterns ppt
Design patterns pptDesign patterns ppt
Design patterns ppt
 
Decorator Pattern
Decorator PatternDecorator Pattern
Decorator Pattern
 
Object-Oriented Design Heuristics
Object-Oriented Design HeuristicsObject-Oriented Design Heuristics
Object-Oriented Design Heuristics
 
Clean architecture
Clean architectureClean architecture
Clean architecture
 
Bridge Design Pattern
Bridge Design PatternBridge Design Pattern
Bridge Design Pattern
 
Sqlite
SqliteSqlite
Sqlite
 
Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design Pattern
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Software Architecture and Design
Software Architecture and DesignSoftware Architecture and Design
Software Architecture and Design
 
Domain Driven Design Introduction
Domain Driven Design IntroductionDomain Driven Design Introduction
Domain Driven Design Introduction
 
Ch9-Software Engineering 9
Ch9-Software Engineering 9Ch9-Software Engineering 9
Ch9-Software Engineering 9
 
Dependency injection presentation
Dependency injection presentationDependency injection presentation
Dependency injection presentation
 
Jedi slides 2.1 object-oriented concepts
Jedi slides 2.1 object-oriented conceptsJedi slides 2.1 object-oriented concepts
Jedi slides 2.1 object-oriented concepts
 
Project management 02112009
Project management 02112009Project management 02112009
Project management 02112009
 

Similar to Design Patterns In Scala

Benefits of using software design patterns and when to use design pattern
Benefits of using software design patterns and when to use design patternBenefits of using software design patterns and when to use design pattern
Benefits of using software design patterns and when to use design pattern
Beroza Paul
 
MWLUG 2015 - An Introduction to MVC
MWLUG 2015 - An Introduction to MVCMWLUG 2015 - An Introduction to MVC
MWLUG 2015 - An Introduction to MVC
Ulrich Krause
 
An Introduction To Model  View  Controller In XPages
An Introduction To Model  View  Controller In XPagesAn Introduction To Model  View  Controller In XPages
An Introduction To Model  View  Controller In XPages
Ulrich Krause
 
Design Patterns - General Introduction
Design Patterns - General IntroductionDesign Patterns - General Introduction
Design Patterns - General Introduction
Asma CHERIF
 
Designpattern
DesignpatternDesignpattern
Designpattern
Srikrishna k
 
Introduction To Design Patterns
Introduction To Design PatternsIntroduction To Design Patterns
Introduction To Design Patterns
sukumarraju6
 
GOF Design pattern with java
GOF Design pattern with javaGOF Design pattern with java
GOF Design pattern with java
Rajiv Gupta
 
Oops design pattern intro
Oops design pattern intro Oops design pattern intro
Oops design pattern intro
anshu_atri
 
Design pattern in an expressive language java script
Design pattern in an expressive language java scriptDesign pattern in an expressive language java script
Design pattern in an expressive language java script
Amit Thakkar
 
Docfacto release 2.4
Docfacto release 2.4Docfacto release 2.4
Docfacto release 2.4
Darren Hudson
 
JavaFX in Action Part I
JavaFX in Action Part IJavaFX in Action Part I
JavaFX in Action Part I
Mohammad Hossein Rimaz
 
Lab 2
Lab 2Lab 2
Lab 2
Mr SMAK
 
Unit IV Software Engineering
Unit IV Software EngineeringUnit IV Software Engineering
Unit IV Software Engineering
Nandhini S
 
Design patterns
Design patternsDesign patterns
Design patterns
Kolade Ibrahim Arowolo
 
Integrating Machine Learning Capabilities into your team
Integrating Machine Learning Capabilities into your teamIntegrating Machine Learning Capabilities into your team
Integrating Machine Learning Capabilities into your team
Cameron Vetter
 
Design pattern in js
Design pattern in jsDesign pattern in js
Design pattern in js
Anil Kumar Suryavansi
 
the Modeling is a way of thinking about the
the Modeling is a way of thinking about thethe Modeling is a way of thinking about the
the Modeling is a way of thinking about the
saman zaker
 
CHAPTER12.ppt
CHAPTER12.pptCHAPTER12.ppt
CHAPTER12.ppt
CharenReposposa
 
Design Concepts in Software Engineering-1.pptx
Design Concepts in Software Engineering-1.pptxDesign Concepts in Software Engineering-1.pptx
Design Concepts in Software Engineering-1.pptx
KarthigaiSelviS3
 
CS8494 SOFTWARE ENGINEERING Unit-3
CS8494 SOFTWARE ENGINEERING Unit-3CS8494 SOFTWARE ENGINEERING Unit-3
CS8494 SOFTWARE ENGINEERING Unit-3
SIMONTHOMAS S
 

Similar to Design Patterns In Scala (20)

Benefits of using software design patterns and when to use design pattern
Benefits of using software design patterns and when to use design patternBenefits of using software design patterns and when to use design pattern
Benefits of using software design patterns and when to use design pattern
 
MWLUG 2015 - An Introduction to MVC
MWLUG 2015 - An Introduction to MVCMWLUG 2015 - An Introduction to MVC
MWLUG 2015 - An Introduction to MVC
 
An Introduction To Model  View  Controller In XPages
An Introduction To Model  View  Controller In XPagesAn Introduction To Model  View  Controller In XPages
An Introduction To Model  View  Controller In XPages
 
Design Patterns - General Introduction
Design Patterns - General IntroductionDesign Patterns - General Introduction
Design Patterns - General Introduction
 
Designpattern
DesignpatternDesignpattern
Designpattern
 
Introduction To Design Patterns
Introduction To Design PatternsIntroduction To Design Patterns
Introduction To Design Patterns
 
GOF Design pattern with java
GOF Design pattern with javaGOF Design pattern with java
GOF Design pattern with java
 
Oops design pattern intro
Oops design pattern intro Oops design pattern intro
Oops design pattern intro
 
Design pattern in an expressive language java script
Design pattern in an expressive language java scriptDesign pattern in an expressive language java script
Design pattern in an expressive language java script
 
Docfacto release 2.4
Docfacto release 2.4Docfacto release 2.4
Docfacto release 2.4
 
JavaFX in Action Part I
JavaFX in Action Part IJavaFX in Action Part I
JavaFX in Action Part I
 
Lab 2
Lab 2Lab 2
Lab 2
 
Unit IV Software Engineering
Unit IV Software EngineeringUnit IV Software Engineering
Unit IV Software Engineering
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Integrating Machine Learning Capabilities into your team
Integrating Machine Learning Capabilities into your teamIntegrating Machine Learning Capabilities into your team
Integrating Machine Learning Capabilities into your team
 
Design pattern in js
Design pattern in jsDesign pattern in js
Design pattern in js
 
the Modeling is a way of thinking about the
the Modeling is a way of thinking about thethe Modeling is a way of thinking about the
the Modeling is a way of thinking about the
 
CHAPTER12.ppt
CHAPTER12.pptCHAPTER12.ppt
CHAPTER12.ppt
 
Design Concepts in Software Engineering-1.pptx
Design Concepts in Software Engineering-1.pptxDesign Concepts in Software Engineering-1.pptx
Design Concepts in Software Engineering-1.pptx
 
CS8494 SOFTWARE ENGINEERING Unit-3
CS8494 SOFTWARE ENGINEERING Unit-3CS8494 SOFTWARE ENGINEERING Unit-3
CS8494 SOFTWARE ENGINEERING Unit-3
 

More from Knoldus Inc.

Terratest - Automation testing of infrastructure
Terratest - Automation testing of infrastructureTerratest - Automation testing of infrastructure
Terratest - Automation testing of infrastructure
Knoldus Inc.
 
Getting Started with Apache Spark (Scala)
Getting Started with Apache Spark (Scala)Getting Started with Apache Spark (Scala)
Getting Started with Apache Spark (Scala)
Knoldus Inc.
 
Secure practices with dot net services.pptx
Secure practices with dot net services.pptxSecure practices with dot net services.pptx
Secure practices with dot net services.pptx
Knoldus Inc.
 
Distributed Cache with dot microservices
Distributed Cache with dot microservicesDistributed Cache with dot microservices
Distributed Cache with dot microservices
Knoldus Inc.
 
Introduction to gRPC Presentation (Java)
Introduction to gRPC Presentation (Java)Introduction to gRPC Presentation (Java)
Introduction to gRPC Presentation (Java)
Knoldus Inc.
 
Using InfluxDB for real-time monitoring in Jmeter
Using InfluxDB for real-time monitoring in JmeterUsing InfluxDB for real-time monitoring in Jmeter
Using InfluxDB for real-time monitoring in Jmeter
Knoldus Inc.
 
Intoduction to KubeVela Presentation (DevOps)
Intoduction to KubeVela Presentation (DevOps)Intoduction to KubeVela Presentation (DevOps)
Intoduction to KubeVela Presentation (DevOps)
Knoldus Inc.
 
Stakeholder Management (Project Management) Presentation
Stakeholder Management (Project Management) PresentationStakeholder Management (Project Management) Presentation
Stakeholder Management (Project Management) Presentation
Knoldus Inc.
 
Introduction To Kaniko (DevOps) Presentation
Introduction To Kaniko (DevOps) PresentationIntroduction To Kaniko (DevOps) Presentation
Introduction To Kaniko (DevOps) Presentation
Knoldus Inc.
 
Efficient Test Environments with Infrastructure as Code (IaC)
Efficient Test Environments with Infrastructure as Code (IaC)Efficient Test Environments with Infrastructure as Code (IaC)
Efficient Test Environments with Infrastructure as Code (IaC)
Knoldus Inc.
 
Exploring Terramate DevOps (Presentation)
Exploring Terramate DevOps (Presentation)Exploring Terramate DevOps (Presentation)
Exploring Terramate DevOps (Presentation)
Knoldus Inc.
 
Clean Code in Test Automation Differentiating Between the Good and the Bad
Clean Code in Test Automation  Differentiating Between the Good and the BadClean Code in Test Automation  Differentiating Between the Good and the Bad
Clean Code in Test Automation Differentiating Between the Good and the Bad
Knoldus Inc.
 
Integrating AI Capabilities in Test Automation
Integrating AI Capabilities in Test AutomationIntegrating AI Capabilities in Test Automation
Integrating AI Capabilities in Test Automation
Knoldus Inc.
 
State Management with NGXS in Angular.pptx
State Management with NGXS in Angular.pptxState Management with NGXS in Angular.pptx
State Management with NGXS in Angular.pptx
Knoldus Inc.
 
Authentication in Svelte using cookies.pptx
Authentication in Svelte using cookies.pptxAuthentication in Svelte using cookies.pptx
Authentication in Svelte using cookies.pptx
Knoldus Inc.
 
OAuth2 Implementation Presentation (Java)
OAuth2 Implementation Presentation (Java)OAuth2 Implementation Presentation (Java)
OAuth2 Implementation Presentation (Java)
Knoldus Inc.
 
Supply chain security with Kubeclarity.pptx
Supply chain security with Kubeclarity.pptxSupply chain security with Kubeclarity.pptx
Supply chain security with Kubeclarity.pptx
Knoldus Inc.
 
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML ParsingMastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
Knoldus Inc.
 
Akka gRPC Essentials A Hands-On Introduction
Akka gRPC Essentials A Hands-On IntroductionAkka gRPC Essentials A Hands-On Introduction
Akka gRPC Essentials A Hands-On Introduction
Knoldus Inc.
 
Entity Core with Core Microservices.pptx
Entity Core with Core Microservices.pptxEntity Core with Core Microservices.pptx
Entity Core with Core Microservices.pptx
Knoldus Inc.
 

More from Knoldus Inc. (20)

Terratest - Automation testing of infrastructure
Terratest - Automation testing of infrastructureTerratest - Automation testing of infrastructure
Terratest - Automation testing of infrastructure
 
Getting Started with Apache Spark (Scala)
Getting Started with Apache Spark (Scala)Getting Started with Apache Spark (Scala)
Getting Started with Apache Spark (Scala)
 
Secure practices with dot net services.pptx
Secure practices with dot net services.pptxSecure practices with dot net services.pptx
Secure practices with dot net services.pptx
 
Distributed Cache with dot microservices
Distributed Cache with dot microservicesDistributed Cache with dot microservices
Distributed Cache with dot microservices
 
Introduction to gRPC Presentation (Java)
Introduction to gRPC Presentation (Java)Introduction to gRPC Presentation (Java)
Introduction to gRPC Presentation (Java)
 
Using InfluxDB for real-time monitoring in Jmeter
Using InfluxDB for real-time monitoring in JmeterUsing InfluxDB for real-time monitoring in Jmeter
Using InfluxDB for real-time monitoring in Jmeter
 
Intoduction to KubeVela Presentation (DevOps)
Intoduction to KubeVela Presentation (DevOps)Intoduction to KubeVela Presentation (DevOps)
Intoduction to KubeVela Presentation (DevOps)
 
Stakeholder Management (Project Management) Presentation
Stakeholder Management (Project Management) PresentationStakeholder Management (Project Management) Presentation
Stakeholder Management (Project Management) Presentation
 
Introduction To Kaniko (DevOps) Presentation
Introduction To Kaniko (DevOps) PresentationIntroduction To Kaniko (DevOps) Presentation
Introduction To Kaniko (DevOps) Presentation
 
Efficient Test Environments with Infrastructure as Code (IaC)
Efficient Test Environments with Infrastructure as Code (IaC)Efficient Test Environments with Infrastructure as Code (IaC)
Efficient Test Environments with Infrastructure as Code (IaC)
 
Exploring Terramate DevOps (Presentation)
Exploring Terramate DevOps (Presentation)Exploring Terramate DevOps (Presentation)
Exploring Terramate DevOps (Presentation)
 
Clean Code in Test Automation Differentiating Between the Good and the Bad
Clean Code in Test Automation  Differentiating Between the Good and the BadClean Code in Test Automation  Differentiating Between the Good and the Bad
Clean Code in Test Automation Differentiating Between the Good and the Bad
 
Integrating AI Capabilities in Test Automation
Integrating AI Capabilities in Test AutomationIntegrating AI Capabilities in Test Automation
Integrating AI Capabilities in Test Automation
 
State Management with NGXS in Angular.pptx
State Management with NGXS in Angular.pptxState Management with NGXS in Angular.pptx
State Management with NGXS in Angular.pptx
 
Authentication in Svelte using cookies.pptx
Authentication in Svelte using cookies.pptxAuthentication in Svelte using cookies.pptx
Authentication in Svelte using cookies.pptx
 
OAuth2 Implementation Presentation (Java)
OAuth2 Implementation Presentation (Java)OAuth2 Implementation Presentation (Java)
OAuth2 Implementation Presentation (Java)
 
Supply chain security with Kubeclarity.pptx
Supply chain security with Kubeclarity.pptxSupply chain security with Kubeclarity.pptx
Supply chain security with Kubeclarity.pptx
 
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML ParsingMastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
 
Akka gRPC Essentials A Hands-On Introduction
Akka gRPC Essentials A Hands-On IntroductionAkka gRPC Essentials A Hands-On Introduction
Akka gRPC Essentials A Hands-On Introduction
 
Entity Core with Core Microservices.pptx
Entity Core with Core Microservices.pptxEntity Core with Core Microservices.pptx
Entity Core with Core Microservices.pptx
 

Recently uploaded

socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
SOCRadar
 
Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
Grant Fritchey
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
Peter Muessig
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Łukasz Chruściel
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
Shane Coughlan
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
Hornet Dynamics
 
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdfRevolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Undress Baby
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
Remote DBA Services
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
Sven Peters
 
What is Master Data Management by PiLog Group
What is Master Data Management by PiLog GroupWhat is Master Data Management by PiLog Group
What is Master Data Management by PiLog Group
aymanquadri279
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
Google
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
Philip Schwarz
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Julian Hyde
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptxLORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
lorraineandreiamcidl
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
kalichargn70th171
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
Aftab Hussain
 

Recently uploaded (20)

socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
 
Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
 
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdfRevolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
 
What is Master Data Management by PiLog Group
What is Master Data Management by PiLog GroupWhat is Master Data Management by PiLog Group
What is Master Data Management by PiLog Group
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptxLORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
 

Design Patterns In Scala

  • 1. Presented By: Vidisha Gupta (Software Consultant @ Knoldus) Design Patterns In Scala
  • 2. Agenda 01 What are Design Patterns? 02 Why do we need design patterns? 03 Categories of design patterns 04 Scala Specific Design Patterns Demo 60 6 0404 0 5
  • 3. What are Design Patterns? Design pattern is a general reusable solution to a commonly occurring problem in software design within a given context. Design patterns are formalized best practices that the programmer can use to solve common problems when designing an application or system.
  • 4. Example - Interface Printer{ void print(String text); } Class InkjetPrinter implements Printer { void print(String text){ // spray ink to the paper, roll the paper etc. } } Printer ticketPrinter = new InkjetPrinter(); Printer ticketPrinter = PrinterFactory.createPrinter("Laser");
  • 5. What do we need design patterns? ● Scalable ● Stable ● Highly cohesive modules ● Minimal coupling ● Communication between designers more efficient ● Give the developer a selection of tried and tested solutions to work with ● Language neutral
  • 7. Creational Design Pattern The creational patterns aim to separate a system from how its objects are created, composed, and represented. They increase the system's flexibility in terms of the what, who, how, and when of object creation. The main ideas behind the creational design patterns are as follows: ● Knowledge encapsulation about the concrete classes ● Hiding details about the actual creation and how objects are combined
  • 8. Structural Design Pattern Design patterns that ease the design by identifying a simple way to realize relationships among entities. The main features of structural design patterns include the following: ● The use of composition to combine the implementations of multiple objects ● Help build a large system made of various components by maintaining a high level of flexibility
  • 9. Behavioral Design Pattern Design patterns that identify common communication patterns among objects and realize these patterns. The main features of behavioral design patterns are as follows: ● What is being described is a process or flow ● The flows are simplified and made understandable ● They accomplish tasks that would be difficult or impossible to achieve with objects
  • 10. Scala Specific Design Patterns ● The Lens Pattern ● Duck Typing ● Memoization ● Pimp Library ● Stackable Traits ● The cake pattern ● Lazy evaluation ● The type class design pattern ● Partial functions ● Implicit Injection
  • 11. The Lens Pattern A Lens is an abstraction from functional programming which helps to deal with a problem of updating complex immutable nested objects.
  • 12. Available implementations There are several implementations in scala: ● scalaz.Lens - if you already have scalaz in a project and you are not bothered to write some code in order to define lens ● Quicklens - easy to use and powerful enough to deal with the described problem ● Sauron - very similar to Quicklens and has a less size but also has less functionality ● Monocle - a powerful library which can help if there is necessity to use lots of lens in a code.
  • 13. Duck Typing ● Duck Typing is a way of programming in which an object passed into a function or method supports all method signatures and attributes expected of that object at run time. ● It allows developers to write code that requires the callers to have some specific methods (but not implement an interface)
  • 14. Pimp my Library ● It provides a way to write extension methods for libraries, which we cannot modify. ● It also helps to achieve better code readability. ● Less boiler plate code than adhoc version
  • 15. Stackable Traits ● Stackable traits is the Scala way to implement the decorator design pattern. ● It involves decoration for the purpose of class composition instead of object composition. ● Stackable traits decorate the core traits at compile time, similar to the way decorator objects modify core objects at run time in the decorator pattern.
  • 16. Memoization Memoization is an optimization technique of caching the output of an expensive function for a particular input and then returning the cached result if the function is called again with the same input parameters.