SlideShare une entreprise Scribd logo
1  sur  20
Télécharger pour lire hors ligne
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!
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?

Contenu connexe

Similaire à 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
 

Similaire à 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
 

Dernier

GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noidabntitsolutionsrishis
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 

Dernier (20)

GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 

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!
  • 6.
  • 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/