SlideShare una empresa de Scribd logo
1 de 20
Descargar para leer sin conexión
PRESENTERS 
with a guest appearance from decorators
HI 
• tomridge2@gmail.com 
• @tjridge 
• github.com/ridget
LETS BUILD AN APP
VIEW RELATED LOGIC 
• welp
LETS PUT IT IN A HELPER!
Rails Presenters
HELPERS AREN’T AWESOME 
• at least for this task 
• they share a global namespace 
• aren’t a very oo way of solving the problem 
• great for shared logic that doesn't relate to the 
object. Use sparingly
I KNOW MODELS! 
• also nope 
• All these if conditions relate to the display of data 
• Don’t overload your model with that level of 
responsibility
ENTER PRESENTERS 
• Presenters are a simple class with knowledge of 
the model and the view. 
• Not a stretch to call them a ViewModel
PURPOSE 
• Presenters help to achieve adherence to SRP 
• A Presenter’s purpose is a decorator who has the 
job of massaging the decorated object into a ui/ 
view friendly manner.
DECORATOR? 
• Taking one object and adding, replacing or 
extending its behaviour, whilst allowing access to 
the underlying objects methods.
PRESENTERS VS DECORATORS 
• A decorator isn’t always a presenter, but a 
presenter is always likely to be a decorator.
END RESULT 
• This is more in line with a decorator approach 
• We just delegate to the underlying object
MULTIPLE OBJECTS? 
• ensure you delegate methods to the underlying 
objects
MULTIPLE RECORDS? 
• Just create a wrap method to instantiate your 
presenter/decorator across multiple records.
OTHER OPTIONS? 
• Draper 
• Great for when things start getting more 
complex
OTHER VALUE POINTS 
• Easy-ish to test 
• less conditionals in your views 
• happier designers/front end developers
CONS 
• More objects == harder to learn the codebase 
• Don’t introduce them until you need to.
GREAT RESOURCES 
• Railscasts - draper and presenters from scratch 
(pro) 
• http://new-bamboo.co.uk/blog/2013/04/17/rails-presenters- 
skinny-everything 
• http://robertomurray.co.uk/blog/2014/decorators-presenters- 
delegators-rails/
QUESTIONS?

Más contenido relacionado

Similar a Rails Presenters

Design Pattern Zoology
Design Pattern ZoologyDesign Pattern Zoology
Design Pattern ZoologyJosh Adell
 
Future Friendly Style Guides
Future Friendly Style GuidesFuture Friendly Style Guides
Future Friendly Style GuidesLuke Brooker
 
A Future Friendly Workflow
A Future Friendly WorkflowA Future Friendly Workflow
A Future Friendly WorkflowLuke Brooker
 
The Design Fortress: Boosting Design Productivity and Creativity in an Agile ...
The Design Fortress: Boosting Design Productivity and Creativity in an Agile ...The Design Fortress: Boosting Design Productivity and Creativity in an Agile ...
The Design Fortress: Boosting Design Productivity and Creativity in an Agile ...David Randall
 
The 360 Developer
The 360 DeveloperThe 360 Developer
The 360 Developerenteritos
 
How to ensure a long life span for a website (WPHelsinki 2.11.2016)
How to ensure a long life span for a website (WPHelsinki 2.11.2016)How to ensure a long life span for a website (WPHelsinki 2.11.2016)
How to ensure a long life span for a website (WPHelsinki 2.11.2016)Teemu Suoranta
 
How to ensure a long life span for a website?
How to ensure a long life span for a website?How to ensure a long life span for a website?
How to ensure a long life span for a website?Teemu Suoranta
 
Creating a Great Portfolio Site
Creating a Great Portfolio SiteCreating a Great Portfolio Site
Creating a Great Portfolio SiteMel Choyce
 
CPP16 - Object Design
CPP16 - Object DesignCPP16 - Object Design
CPP16 - Object DesignMichael Heron
 
Planning Patterns for Agile Testers
Planning Patterns for Agile TestersPlanning Patterns for Agile Testers
Planning Patterns for Agile TestersGerrit Beine
 
Untangling - fall2017 - week 7
Untangling - fall2017 - week 7Untangling - fall2017 - week 7
Untangling - fall2017 - week 7Derek Jacoby
 
Exhibits and Presenters
Exhibits and PresentersExhibits and Presenters
Exhibits and Presentersatifzia14
 
Colin sullivan successful-project-presentation
Colin sullivan successful-project-presentationColin sullivan successful-project-presentation
Colin sullivan successful-project-presentationmskmoorthy
 
Create Your Own Starter Files
Create Your Own Starter FilesCreate Your Own Starter Files
Create Your Own Starter FilesEmily Lewis
 

Similar a Rails Presenters (20)

Design Pattern Zoology
Design Pattern ZoologyDesign Pattern Zoology
Design Pattern Zoology
 
Software development fundamentals
Software development fundamentalsSoftware development fundamentals
Software development fundamentals
 
Future Friendly Style Guides
Future Friendly Style GuidesFuture Friendly Style Guides
Future Friendly Style Guides
 
Objectify Your Code
Objectify Your CodeObjectify Your Code
Objectify Your Code
 
A Future Friendly Workflow
A Future Friendly WorkflowA Future Friendly Workflow
A Future Friendly Workflow
 
The Design Fortress: Boosting Design Productivity and Creativity in an Agile ...
The Design Fortress: Boosting Design Productivity and Creativity in an Agile ...The Design Fortress: Boosting Design Productivity and Creativity in an Agile ...
The Design Fortress: Boosting Design Productivity and Creativity in an Agile ...
 
The 360 Developer
The 360 DeveloperThe 360 Developer
The 360 Developer
 
How to ensure a long life span for a website (WPHelsinki 2.11.2016)
How to ensure a long life span for a website (WPHelsinki 2.11.2016)How to ensure a long life span for a website (WPHelsinki 2.11.2016)
How to ensure a long life span for a website (WPHelsinki 2.11.2016)
 
How to ensure a long life span for a website?
How to ensure a long life span for a website?How to ensure a long life span for a website?
How to ensure a long life span for a website?
 
Creating a Great Portfolio Site
Creating a Great Portfolio SiteCreating a Great Portfolio Site
Creating a Great Portfolio Site
 
Beyond the rails way
Beyond the rails wayBeyond the rails way
Beyond the rails way
 
CPP16 - Object Design
CPP16 - Object DesignCPP16 - Object Design
CPP16 - Object Design
 
Planning Patterns for Agile Testers
Planning Patterns for Agile TestersPlanning Patterns for Agile Testers
Planning Patterns for Agile Testers
 
Untangling - fall2017 - week 7
Untangling - fall2017 - week 7Untangling - fall2017 - week 7
Untangling - fall2017 - week 7
 
Draper - Visnupriya - spriteXchange
Draper - Visnupriya - spriteXchangeDraper - Visnupriya - spriteXchange
Draper - Visnupriya - spriteXchange
 
Exhibits and Presenters
Exhibits and PresentersExhibits and Presenters
Exhibits and Presenters
 
Decorator Pattern
Decorator PatternDecorator Pattern
Decorator Pattern
 
Colin sullivan successful-project-presentation
Colin sullivan successful-project-presentationColin sullivan successful-project-presentation
Colin sullivan successful-project-presentation
 
Create Your Own Starter Files
Create Your Own Starter FilesCreate Your Own Starter Files
Create Your Own Starter Files
 
Designing for Everybody Workshop
Designing for Everybody WorkshopDesigning for Everybody Workshop
Designing for Everybody Workshop
 

Último

Webinar_050417_LeClair12345666777889.ppt
Webinar_050417_LeClair12345666777889.pptWebinar_050417_LeClair12345666777889.ppt
Webinar_050417_LeClair12345666777889.pptkinjal48
 
Growing Oxen: channel operators and retries
Growing Oxen: channel operators and retriesGrowing Oxen: channel operators and retries
Growing Oxen: channel operators and retriesSoftwareMill
 
Fields in Java and Kotlin and what to expect.pptx
Fields in Java and Kotlin and what to expect.pptxFields in Java and Kotlin and what to expect.pptx
Fields in Java and Kotlin and what to expect.pptxJoão Esperancinha
 
How Does the Epitome of Spyware Differ from Other Malicious Software?
How Does the Epitome of Spyware Differ from Other Malicious Software?How Does the Epitome of Spyware Differ from Other Malicious Software?
How Does the Epitome of Spyware Differ from Other Malicious Software?AmeliaSmith90
 
Leveraging DxSherpa's Generative AI Services to Unlock Human-Machine Harmony
Leveraging DxSherpa's Generative AI Services to Unlock Human-Machine HarmonyLeveraging DxSherpa's Generative AI Services to Unlock Human-Machine Harmony
Leveraging DxSherpa's Generative AI Services to Unlock Human-Machine Harmonyelliciumsolutionspun
 
Enterprise Document Management System - Qualityze Inc
Enterprise Document Management System - Qualityze IncEnterprise Document Management System - Qualityze Inc
Enterprise Document Management System - Qualityze Incrobinwilliams8624
 
IA Generativa y Grafos de Neo4j: RAG time
IA Generativa y Grafos de Neo4j: RAG timeIA Generativa y Grafos de Neo4j: RAG time
IA Generativa y Grafos de Neo4j: RAG timeNeo4j
 
OpenChain Webinar: Universal CVSS Calculator
OpenChain Webinar: Universal CVSS CalculatorOpenChain Webinar: Universal CVSS Calculator
OpenChain Webinar: Universal CVSS CalculatorShane Coughlan
 
ERP For Electrical and Electronics manufecturing.pptx
ERP For Electrical and Electronics manufecturing.pptxERP For Electrical and Electronics manufecturing.pptx
ERP For Electrical and Electronics manufecturing.pptxAutus Cyber Tech
 
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/MLBig Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/MLAlluxio, Inc.
 
AI Embracing Every Shade of Human Beauty
AI Embracing Every Shade of Human BeautyAI Embracing Every Shade of Human Beauty
AI Embracing Every Shade of Human BeautyRaymond Okyere-Forson
 
Generative AI for Cybersecurity - EC-Council
Generative AI for Cybersecurity - EC-CouncilGenerative AI for Cybersecurity - EC-Council
Generative AI for Cybersecurity - EC-CouncilVICTOR MAESTRE RAMIREZ
 
Kawika Technologies pvt ltd Software Development Company in Trivandrum
Kawika Technologies pvt ltd Software Development Company in TrivandrumKawika Technologies pvt ltd Software Development Company in Trivandrum
Kawika Technologies pvt ltd Software Development Company in TrivandrumKawika Technologies
 
Watermarking in Source Code: Applications and Security Challenges
Watermarking in Source Code: Applications and Security ChallengesWatermarking in Source Code: Applications and Security Challenges
Watermarking in Source Code: Applications and Security ChallengesShyamsundar Das
 
Introduction-to-Software-Development-Outsourcing.pptx
Introduction-to-Software-Development-Outsourcing.pptxIntroduction-to-Software-Development-Outsourcing.pptx
Introduction-to-Software-Development-Outsourcing.pptxIntelliSource Technologies
 
Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...
Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...
Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...OnePlan Solutions
 
Why Choose Brain Inventory For Ecommerce Development.pdf
Why Choose Brain Inventory For Ecommerce Development.pdfWhy Choose Brain Inventory For Ecommerce Development.pdf
Why Choose Brain Inventory For Ecommerce Development.pdfBrain Inventory
 
Streamlining Your Application Builds with Cloud Native Buildpacks
Streamlining Your Application Builds  with Cloud Native BuildpacksStreamlining Your Application Builds  with Cloud Native Buildpacks
Streamlining Your Application Builds with Cloud Native BuildpacksVish Abrams
 
JS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AIJS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AIIvo Andreev
 

Último (20)

Salesforce AI Associate Certification.pptx
Salesforce AI Associate Certification.pptxSalesforce AI Associate Certification.pptx
Salesforce AI Associate Certification.pptx
 
Webinar_050417_LeClair12345666777889.ppt
Webinar_050417_LeClair12345666777889.pptWebinar_050417_LeClair12345666777889.ppt
Webinar_050417_LeClair12345666777889.ppt
 
Growing Oxen: channel operators and retries
Growing Oxen: channel operators and retriesGrowing Oxen: channel operators and retries
Growing Oxen: channel operators and retries
 
Fields in Java and Kotlin and what to expect.pptx
Fields in Java and Kotlin and what to expect.pptxFields in Java and Kotlin and what to expect.pptx
Fields in Java and Kotlin and what to expect.pptx
 
How Does the Epitome of Spyware Differ from Other Malicious Software?
How Does the Epitome of Spyware Differ from Other Malicious Software?How Does the Epitome of Spyware Differ from Other Malicious Software?
How Does the Epitome of Spyware Differ from Other Malicious Software?
 
Leveraging DxSherpa's Generative AI Services to Unlock Human-Machine Harmony
Leveraging DxSherpa's Generative AI Services to Unlock Human-Machine HarmonyLeveraging DxSherpa's Generative AI Services to Unlock Human-Machine Harmony
Leveraging DxSherpa's Generative AI Services to Unlock Human-Machine Harmony
 
Enterprise Document Management System - Qualityze Inc
Enterprise Document Management System - Qualityze IncEnterprise Document Management System - Qualityze Inc
Enterprise Document Management System - Qualityze Inc
 
IA Generativa y Grafos de Neo4j: RAG time
IA Generativa y Grafos de Neo4j: RAG timeIA Generativa y Grafos de Neo4j: RAG time
IA Generativa y Grafos de Neo4j: RAG time
 
OpenChain Webinar: Universal CVSS Calculator
OpenChain Webinar: Universal CVSS CalculatorOpenChain Webinar: Universal CVSS Calculator
OpenChain Webinar: Universal CVSS Calculator
 
ERP For Electrical and Electronics manufecturing.pptx
ERP For Electrical and Electronics manufecturing.pptxERP For Electrical and Electronics manufecturing.pptx
ERP For Electrical and Electronics manufecturing.pptx
 
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/MLBig Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
 
AI Embracing Every Shade of Human Beauty
AI Embracing Every Shade of Human BeautyAI Embracing Every Shade of Human Beauty
AI Embracing Every Shade of Human Beauty
 
Generative AI for Cybersecurity - EC-Council
Generative AI for Cybersecurity - EC-CouncilGenerative AI for Cybersecurity - EC-Council
Generative AI for Cybersecurity - EC-Council
 
Kawika Technologies pvt ltd Software Development Company in Trivandrum
Kawika Technologies pvt ltd Software Development Company in TrivandrumKawika Technologies pvt ltd Software Development Company in Trivandrum
Kawika Technologies pvt ltd Software Development Company in Trivandrum
 
Watermarking in Source Code: Applications and Security Challenges
Watermarking in Source Code: Applications and Security ChallengesWatermarking in Source Code: Applications and Security Challenges
Watermarking in Source Code: Applications and Security Challenges
 
Introduction-to-Software-Development-Outsourcing.pptx
Introduction-to-Software-Development-Outsourcing.pptxIntroduction-to-Software-Development-Outsourcing.pptx
Introduction-to-Software-Development-Outsourcing.pptx
 
Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...
Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...
Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...
 
Why Choose Brain Inventory For Ecommerce Development.pdf
Why Choose Brain Inventory For Ecommerce Development.pdfWhy Choose Brain Inventory For Ecommerce Development.pdf
Why Choose Brain Inventory For Ecommerce Development.pdf
 
Streamlining Your Application Builds with Cloud Native Buildpacks
Streamlining Your Application Builds  with Cloud Native BuildpacksStreamlining Your Application Builds  with Cloud Native Buildpacks
Streamlining Your Application Builds with Cloud Native Buildpacks
 
JS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AIJS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AI
 

Rails Presenters

  • 1. PRESENTERS with a guest appearance from decorators
  • 2. HI • tomridge2@gmail.com • @tjridge • github.com/ridget
  • 5. LETS PUT IT IN A HELPER!
  • 7. HELPERS AREN’T AWESOME • at least for this task • they share a global namespace • aren’t a very oo way of solving the problem • great for shared logic that doesn't relate to the object. Use sparingly
  • 8. I KNOW MODELS! • also nope • All these if conditions relate to the display of data • Don’t overload your model with that level of responsibility
  • 9. ENTER PRESENTERS • Presenters are a simple class with knowledge of the model and the view. • Not a stretch to call them a ViewModel
  • 10. PURPOSE • Presenters help to achieve adherence to SRP • A Presenter’s purpose is a decorator who has the job of massaging the decorated object into a ui/ view friendly manner.
  • 11. DECORATOR? • Taking one object and adding, replacing or extending its behaviour, whilst allowing access to the underlying objects methods.
  • 12. PRESENTERS VS DECORATORS • A decorator isn’t always a presenter, but a presenter is always likely to be a decorator.
  • 13. END RESULT • This is more in line with a decorator approach • We just delegate to the underlying object
  • 14. MULTIPLE OBJECTS? • ensure you delegate methods to the underlying objects
  • 15. MULTIPLE RECORDS? • Just create a wrap method to instantiate your presenter/decorator across multiple records.
  • 16. OTHER OPTIONS? • Draper • Great for when things start getting more complex
  • 17. OTHER VALUE POINTS • Easy-ish to test • less conditionals in your views • happier designers/front end developers
  • 18. CONS • More objects == harder to learn the codebase • Don’t introduce them until you need to.
  • 19. GREAT RESOURCES • Railscasts - draper and presenters from scratch (pro) • http://new-bamboo.co.uk/blog/2013/04/17/rails-presenters- skinny-everything • http://robertomurray.co.uk/blog/2014/decorators-presenters- delegators-rails/