SlideShare a Scribd company logo
1 of 12
Show and tell:
Generator patterns and new use
cases
Gireesh Punathil, IBM India
gpunathi@in.ibm.com | @gireeshpunam | https://github.com/gireeshpunathil
Agenda
• Functional Programming
• Continuation passing style
• Closures and Closure Contexts
• Iterator patterns
• Generator patterns
• Generator pattern use cases
• Summary
7/28/2017 Eclipse summit India 2017 2
Functional Programming
• A programming language paradigm in which computation is the
evaluation of function(s)
• Functions as first class variables
• Higher order functions
7/28/2017 Eclipse summit India 2017 3
Continuation Passing Style
• A functional programming style in which the caller delegates both the
current as well as the continuation control flow to the callee.
Continuation retention style Continuation passing style
7/28/2017 Eclipse summit India 2017 4
Closure
• Binding of a function and its operating environment that is defined in
the lexical scope of an enclosing function.
7/28/2017 Eclipse summit India 2017 5
Closure context
• The operating environment that is defined in the lexical scope of an
enclosing function.
7/28/2017 Eclipse summit India 2017 6
Iterator Pattern
• An object oriented programming pattern which defines an
Enumerator interface that traverses Components in a Container
7/28/2017 Eclipse summit India 2017 7
Java Javascript
Generator Pattern
• An programming pattern which defines an Controller interface for
incrementally traversing a data structure / executing a code sequence
7/28/2017 Eclipse summit India 2017 8
Generator Pattern Use cases: #1
• Simple iterator over heterogeneous collections
7/28/2017 Eclipse summit India 2017 9
Generator Pattern Use cases: #2
• Implement stream sources in a clean manner
7/28/2017 Eclipse summit India 2017 10
Generator Pattern Use cases: #3
• Traverse deeply nested data structures, yield intermediary values
while retaining the traversal context
7/28/2017 Eclipse summit India 2017 11
Further reading
Functional Programming
https://en.wikipedia.org/wiki/Functional_programming
Continuation passing style
https://en.wikipedia.org/wiki/Continuation-passing_style
Closures and Closure Contexts
https://www.ibm.com/developerworks/library/wa-use-javascript-
closures-efficiently
Iterators and Generators
https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Iterators
_and_Generators
7/28/2017 Eclipse summit India 2017 12

More Related Content

Similar to Generator patterns

Search summit-2018-content-engineering-slides
Search summit-2018-content-engineering-slidesSearch summit-2018-content-engineering-slides
Search summit-2018-content-engineering-slidesSujit Pal
 
Creating abstractions from scientific workflows: PhD symposium 2015
Creating abstractions from scientific workflows: PhD symposium 2015Creating abstractions from scientific workflows: PhD symposium 2015
Creating abstractions from scientific workflows: PhD symposium 2015dgarijo
 
Predictable reactive state management - ngrx
Predictable reactive state management - ngrxPredictable reactive state management - ngrx
Predictable reactive state management - ngrxIlia Idakiev
 
IM in Graph 2017-05.pdf
IM in Graph 2017-05.pdfIM in Graph 2017-05.pdf
IM in Graph 2017-05.pdfMichal Miklas
 
Web Server Programming - Chapter 1
Web Server Programming - Chapter 1Web Server Programming - Chapter 1
Web Server Programming - Chapter 1Nicole Ryan
 
Lecture: Refactoring
Lecture: RefactoringLecture: Refactoring
Lecture: RefactoringMarcus Denker
 
Let's explore Helix by Gopikrishna Gujjula
Let's explore Helix by Gopikrishna GujjulaLet's explore Helix by Gopikrishna Gujjula
Let's explore Helix by Gopikrishna GujjulaAnindita Bhattacharya
 
Introduction to Design Patterns in Javascript
Introduction to Design Patterns in JavascriptIntroduction to Design Patterns in Javascript
Introduction to Design Patterns in JavascriptSanthosh Kumar Srinivasan
 
Growth and evolution of Open-Tamil
Growth and evolution of Open-TamilGrowth and evolution of Open-Tamil
Growth and evolution of Open-Tamilezhillang
 
Index conf sparkml-feb20-n-pentreath
Index conf sparkml-feb20-n-pentreathIndex conf sparkml-feb20-n-pentreath
Index conf sparkml-feb20-n-pentreathChester Chen
 
Data Integration Solutions Created By Koneksys
Data Integration Solutions Created By KoneksysData Integration Solutions Created By Koneksys
Data Integration Solutions Created By KoneksysKoneksys
 
How to Lower the Cost of Deploying Analytics: An Introduction to the Portable...
How to Lower the Cost of Deploying Analytics: An Introduction to the Portable...How to Lower the Cost of Deploying Analytics: An Introduction to the Portable...
How to Lower the Cost of Deploying Analytics: An Introduction to the Portable...Robert Grossman
 
System design process.pptx
System design process.pptxSystem design process.pptx
System design process.pptxNajibMuhammad16
 
Mulvery Detail - English
Mulvery Detail - EnglishMulvery Detail - English
Mulvery Detail - EnglishDaichi Teruya
 
ATAGTR2017 Protractor Cucumber BDD Approach
ATAGTR2017 Protractor Cucumber BDD ApproachATAGTR2017 Protractor Cucumber BDD Approach
ATAGTR2017 Protractor Cucumber BDD ApproachAgile Testing Alliance
 

Similar to Generator patterns (20)

GraphQL 101
GraphQL 101GraphQL 101
GraphQL 101
 
Search summit-2018-content-engineering-slides
Search summit-2018-content-engineering-slidesSearch summit-2018-content-engineering-slides
Search summit-2018-content-engineering-slides
 
Creating abstractions from scientific workflows: PhD symposium 2015
Creating abstractions from scientific workflows: PhD symposium 2015Creating abstractions from scientific workflows: PhD symposium 2015
Creating abstractions from scientific workflows: PhD symposium 2015
 
Predictable reactive state management - ngrx
Predictable reactive state management - ngrxPredictable reactive state management - ngrx
Predictable reactive state management - ngrx
 
IM in Graph 2017-05.pdf
IM in Graph 2017-05.pdfIM in Graph 2017-05.pdf
IM in Graph 2017-05.pdf
 
Web Server Programming - Chapter 1
Web Server Programming - Chapter 1Web Server Programming - Chapter 1
Web Server Programming - Chapter 1
 
Final Algos
Final AlgosFinal Algos
Final Algos
 
Lecture: Refactoring
Lecture: RefactoringLecture: Refactoring
Lecture: Refactoring
 
Lets explore sitecore helix
Lets explore sitecore helixLets explore sitecore helix
Lets explore sitecore helix
 
Let's explore Helix by Gopikrishna Gujjula
Let's explore Helix by Gopikrishna GujjulaLet's explore Helix by Gopikrishna Gujjula
Let's explore Helix by Gopikrishna Gujjula
 
Introduction to Design Patterns in Javascript
Introduction to Design Patterns in JavascriptIntroduction to Design Patterns in Javascript
Introduction to Design Patterns in Javascript
 
PM Symposium RUP UC Realization
PM Symposium RUP UC RealizationPM Symposium RUP UC Realization
PM Symposium RUP UC Realization
 
Growth and evolution of Open-Tamil
Growth and evolution of Open-TamilGrowth and evolution of Open-Tamil
Growth and evolution of Open-Tamil
 
Index conf sparkml-feb20-n-pentreath
Index conf sparkml-feb20-n-pentreathIndex conf sparkml-feb20-n-pentreath
Index conf sparkml-feb20-n-pentreath
 
Data Integration Solutions Created By Koneksys
Data Integration Solutions Created By KoneksysData Integration Solutions Created By Koneksys
Data Integration Solutions Created By Koneksys
 
How to Lower the Cost of Deploying Analytics: An Introduction to the Portable...
How to Lower the Cost of Deploying Analytics: An Introduction to the Portable...How to Lower the Cost of Deploying Analytics: An Introduction to the Portable...
How to Lower the Cost of Deploying Analytics: An Introduction to the Portable...
 
System design process.pptx
System design process.pptxSystem design process.pptx
System design process.pptx
 
Mulvery Detail - English
Mulvery Detail - EnglishMulvery Detail - English
Mulvery Detail - English
 
ATAGTR2017 Protractor Cucumber BDD Approach
ATAGTR2017 Protractor Cucumber BDD ApproachATAGTR2017 Protractor Cucumber BDD Approach
ATAGTR2017 Protractor Cucumber BDD Approach
 
MDE in Practice
MDE in PracticeMDE in Practice
MDE in Practice
 

Recently uploaded

HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 

Recently uploaded (20)

HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 

Generator patterns

  • 1. Show and tell: Generator patterns and new use cases Gireesh Punathil, IBM India gpunathi@in.ibm.com | @gireeshpunam | https://github.com/gireeshpunathil
  • 2. Agenda • Functional Programming • Continuation passing style • Closures and Closure Contexts • Iterator patterns • Generator patterns • Generator pattern use cases • Summary 7/28/2017 Eclipse summit India 2017 2
  • 3. Functional Programming • A programming language paradigm in which computation is the evaluation of function(s) • Functions as first class variables • Higher order functions 7/28/2017 Eclipse summit India 2017 3
  • 4. Continuation Passing Style • A functional programming style in which the caller delegates both the current as well as the continuation control flow to the callee. Continuation retention style Continuation passing style 7/28/2017 Eclipse summit India 2017 4
  • 5. Closure • Binding of a function and its operating environment that is defined in the lexical scope of an enclosing function. 7/28/2017 Eclipse summit India 2017 5
  • 6. Closure context • The operating environment that is defined in the lexical scope of an enclosing function. 7/28/2017 Eclipse summit India 2017 6
  • 7. Iterator Pattern • An object oriented programming pattern which defines an Enumerator interface that traverses Components in a Container 7/28/2017 Eclipse summit India 2017 7 Java Javascript
  • 8. Generator Pattern • An programming pattern which defines an Controller interface for incrementally traversing a data structure / executing a code sequence 7/28/2017 Eclipse summit India 2017 8
  • 9. Generator Pattern Use cases: #1 • Simple iterator over heterogeneous collections 7/28/2017 Eclipse summit India 2017 9
  • 10. Generator Pattern Use cases: #2 • Implement stream sources in a clean manner 7/28/2017 Eclipse summit India 2017 10
  • 11. Generator Pattern Use cases: #3 • Traverse deeply nested data structures, yield intermediary values while retaining the traversal context 7/28/2017 Eclipse summit India 2017 11
  • 12. Further reading Functional Programming https://en.wikipedia.org/wiki/Functional_programming Continuation passing style https://en.wikipedia.org/wiki/Continuation-passing_style Closures and Closure Contexts https://www.ibm.com/developerworks/library/wa-use-javascript- closures-efficiently Iterators and Generators https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Iterators _and_Generators 7/28/2017 Eclipse summit India 2017 12