SlideShare ist ein Scribd-Unternehmen logo
1 von 22
Concerns and 
Presenters 
By - Aaditi Jain
Concerns
Concern : Structure
Concern : Dependency
Concern : Dependency 
Methods of a concern are not invoked until the concern is included in something that is not a 
concern.
Concerns in Models : DRYing 
Example : Consider a Article model, a Event model and a Comment Model. An article or an event 
has_many comments. A comment belongs_to either article or event.
Concerns in Models : DRYing
Concerns in Models : DRYing
Concerns in Models : Modularization 
Example : Consider a Event model. A event has many attenders and comments. Typically, 
the event model might look like this:
Concerns in Models : Modularization
Concerns In Controllers : 
Modularization and DRYing 
Concerns can be used in Controllers in a similar way as in Models. 
Example: 
• An Users controller, an Articles Controller, an Events Controller. 
• A User has to login to view all the articles and events . 
• Typically: Both Articles and Events controller will have some logic to check 
that the user has logged in etc. 
• Concerns : Shift all the common logic related to user in Article and Event 
controller into a concern module called Authorizable. Then Include this 
Authorizable module in Articles and Events Controller.
Concerns: Placement and Logic 
Placement 
• If only one concern per model/controller or One concern is being included by 
multiple models/controllers: Place them directly under the concerns folder. 
app/controller/concern/authorizable.rb 
app/model/concern/commentable.rb 
• If many concerns per model/controller: Create a folder inside the concerns 
with the name of the model/controller and place them inside it. 
app/model/event/attendable.rb 
Logic: 
Concerns should be domain based rather than technical based. For Example : 
For a model, domain based concerns will be like ‘Commentable’, ‘Taggable’, 
While technical based concerns will be ‘FinderMethod’, ‘ValidationMethod’
Concerns: Pros and Cons 
Pros 
• Easy to Use for refactoring. 
• No external dependency 
Cons 
• Modules Problem 
• Debugging is tougher 
• No actual reduction in code. Its just better organized.
Presenters
Example : 
Consider an application with this setup :
Problems With this Approach 
• Multiple Instance Variables in Controllers : 
1) Violation Of Sandi Metz Rule : One Controller action may pass only one 
instance variable to its corresponding view. 
2) Seperation of Concern in Controllers 
• Logic creeping In the view files 
Solutions : Include Logic as Models Methods 
Include Logic in Helpers
Presenters : A Design Pattern
Presenters : A Design Pattern 
Create a folder in your app directory with name ‘presenters’. Create a .rb file 
specific to the model we are working with (user in our case)
Presenters : A Design Pattern
Presenters Pros and Cons 
Pros 
• Introduces Object-Oriented-ness in the View Layer 
• Clean Controllers and Views 
• Easy Testing. 
Cons 
• Generating this additional layer is a overhead.
Thank You :)
References 
• https://github.com/justin808/fat-code-refactoring-techniques 
• http://railscasts.com/episodes/287-presenters-from-scratch 
• http://sokolmichael.com/posts/2012-01-14-model-view- 
controller-presenter-better-separation-of-concern 
• https://www.youtube.com/watch?v=VC5z8nadnQE

Weitere ähnliche Inhalte

Was ist angesagt?

Finding Defects in C#: Coverity vs. FxCop
Finding Defects in C#: Coverity vs. FxCopFinding Defects in C#: Coverity vs. FxCop
Finding Defects in C#: Coverity vs. FxCopCoverity
 
TDD — Are you sure you properly test code?
TDD — Are you sure you properly test code?TDD — Are you sure you properly test code?
TDD — Are you sure you properly test code?Dmitriy Nesteryuk
 
Refactoring Applications using SOLID Principles
Refactoring Applications using SOLID PrinciplesRefactoring Applications using SOLID Principles
Refactoring Applications using SOLID PrinciplesSteven Smith
 
Static Analysis Primer
Static Analysis PrimerStatic Analysis Primer
Static Analysis PrimerCoverity
 
Code review
Code reviewCode review
Code reviewdqpi
 
Java Design Patterns Tutorial | Edureka
Java Design Patterns Tutorial | EdurekaJava Design Patterns Tutorial | Edureka
Java Design Patterns Tutorial | EdurekaEdureka!
 
Code Review Best Practices
Code Review Best PracticesCode Review Best Practices
Code Review Best PracticesTrisha Gee
 
GOF Design pattern with java
GOF Design pattern with javaGOF Design pattern with java
GOF Design pattern with javaRajiv Gupta
 
Working with Legacy Code
Working with Legacy CodeWorking with Legacy Code
Working with Legacy CodeEyal Golan
 
Intro to programing with java-lecture 1
Intro to programing with java-lecture 1Intro to programing with java-lecture 1
Intro to programing with java-lecture 1Mohamed Essam
 
DevBeat 2013 - Developer-first Security
DevBeat 2013 - Developer-first SecurityDevBeat 2013 - Developer-first Security
DevBeat 2013 - Developer-first SecurityCoverity
 
Are Agile Projects Doomed to Half-Baked Design?
Are Agile Projects Doomed to Half-Baked Design?Are Agile Projects Doomed to Half-Baked Design?
Are Agile Projects Doomed to Half-Baked Design?theinfonaut
 
Code review guidelines
Code review guidelinesCode review guidelines
Code review guidelinesLalit Kale
 

Was ist angesagt? (19)

Finding Defects in C#: Coverity vs. FxCop
Finding Defects in C#: Coverity vs. FxCopFinding Defects in C#: Coverity vs. FxCop
Finding Defects in C#: Coverity vs. FxCop
 
Code Review for iOS
Code Review for iOSCode Review for iOS
Code Review for iOS
 
TDD — Are you sure you properly test code?
TDD — Are you sure you properly test code?TDD — Are you sure you properly test code?
TDD — Are you sure you properly test code?
 
Refactoring Applications using SOLID Principles
Refactoring Applications using SOLID PrinciplesRefactoring Applications using SOLID Principles
Refactoring Applications using SOLID Principles
 
Code Review
Code ReviewCode Review
Code Review
 
Static Analysis Primer
Static Analysis PrimerStatic Analysis Primer
Static Analysis Primer
 
Code review
Code reviewCode review
Code review
 
Java Design Patterns Tutorial | Edureka
Java Design Patterns Tutorial | EdurekaJava Design Patterns Tutorial | Edureka
Java Design Patterns Tutorial | Edureka
 
Code Review Best Practices
Code Review Best PracticesCode Review Best Practices
Code Review Best Practices
 
GOF Design pattern with java
GOF Design pattern with javaGOF Design pattern with java
GOF Design pattern with java
 
Working with Legacy Code
Working with Legacy CodeWorking with Legacy Code
Working with Legacy Code
 
Software Design Patterns
Software Design PatternsSoftware Design Patterns
Software Design Patterns
 
Intro to programing with java-lecture 1
Intro to programing with java-lecture 1Intro to programing with java-lecture 1
Intro to programing with java-lecture 1
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Software Design Patterns
Software Design PatternsSoftware Design Patterns
Software Design Patterns
 
DevBeat 2013 - Developer-first Security
DevBeat 2013 - Developer-first SecurityDevBeat 2013 - Developer-first Security
DevBeat 2013 - Developer-first Security
 
Code Review
Code ReviewCode Review
Code Review
 
Are Agile Projects Doomed to Half-Baked Design?
Are Agile Projects Doomed to Half-Baked Design?Are Agile Projects Doomed to Half-Baked Design?
Are Agile Projects Doomed to Half-Baked Design?
 
Code review guidelines
Code review guidelinesCode review guidelines
Code review guidelines
 

Ähnlich wie Concerns and Presenters in Rails

Software Engineering with Objects (M363) Final Revision By Kuwait10
Software Engineering with Objects (M363) Final Revision By Kuwait10Software Engineering with Objects (M363) Final Revision By Kuwait10
Software Engineering with Objects (M363) Final Revision By Kuwait10Kuwait10
 
Applying design patterns
Applying design patternsApplying design patterns
Applying design patternsYogeshwaranT
 
Jay Callicott Drupal Views 2.0 Presentation
Jay Callicott Drupal Views 2.0 PresentationJay Callicott Drupal Views 2.0 Presentation
Jay Callicott Drupal Views 2.0 PresentationMediacurrent
 
Module 2 design patterns-2
Module 2   design patterns-2Module 2   design patterns-2
Module 2 design patterns-2Ankit Dubey
 
Object Oriented Analysis and Design with UML2 part2
Object Oriented Analysis and Design with UML2 part2Object Oriented Analysis and Design with UML2 part2
Object Oriented Analysis and Design with UML2 part2Haitham Raik
 
The Art and Science of Requirements Gathering
The Art and Science of Requirements GatheringThe Art and Science of Requirements Gathering
The Art and Science of Requirements GatheringVanessa Turke
 
Object Oriented System Design
Object Oriented System DesignObject Oriented System Design
Object Oriented System DesignMurugeswari Ravi
 
Chapter 1 intr m dfina
Chapter 1 intr m dfinaChapter 1 intr m dfina
Chapter 1 intr m dfinaKhalil Alhatab
 
The company which asked you to install a web server and properly s.docx
The company which asked you to install a web server and properly s.docxThe company which asked you to install a web server and properly s.docx
The company which asked you to install a web server and properly s.docxmehek4
 
Designing and documenting software architecture unit 5
Designing and documenting software architecture unit 5Designing and documenting software architecture unit 5
Designing and documenting software architecture unit 5Sudarshan Dhondaley
 
Chapter 3.pptx
Chapter 3.pptxChapter 3.pptx
Chapter 3.pptxTekle12
 
Chapter 1 intr m dfina
Chapter 1 intr m dfinaChapter 1 intr m dfina
Chapter 1 intr m dfinaKhalil Alhatab
 
11 - Evaluating Framework in Interaction Design_new.pptx
11 - Evaluating Framework in Interaction Design_new.pptx11 - Evaluating Framework in Interaction Design_new.pptx
11 - Evaluating Framework in Interaction Design_new.pptxZahirahZairul2
 
03 Analyzing The Problem
03 Analyzing The Problem03 Analyzing The Problem
03 Analyzing The ProblemSandeep Ganji
 
Advanced Software Engineering.ppt
Advanced Software Engineering.pptAdvanced Software Engineering.ppt
Advanced Software Engineering.pptRvishnupriya2
 

Ähnlich wie Concerns and Presenters in Rails (20)

Software Engineering with Objects (M363) Final Revision By Kuwait10
Software Engineering with Objects (M363) Final Revision By Kuwait10Software Engineering with Objects (M363) Final Revision By Kuwait10
Software Engineering with Objects (M363) Final Revision By Kuwait10
 
Applying design patterns
Applying design patternsApplying design patterns
Applying design patterns
 
Unit 2
Unit 2Unit 2
Unit 2
 
Jay Callicott Drupal Views 2.0 Presentation
Jay Callicott Drupal Views 2.0 PresentationJay Callicott Drupal Views 2.0 Presentation
Jay Callicott Drupal Views 2.0 Presentation
 
Module 2 design patterns-2
Module 2   design patterns-2Module 2   design patterns-2
Module 2 design patterns-2
 
Object Oriented Analysis and Design with UML2 part2
Object Oriented Analysis and Design with UML2 part2Object Oriented Analysis and Design with UML2 part2
Object Oriented Analysis and Design with UML2 part2
 
Se lec1 (1)
Se lec1 (1)Se lec1 (1)
Se lec1 (1)
 
Design patterns
Design patternsDesign patterns
Design patterns
 
The Art and Science of Requirements Gathering
The Art and Science of Requirements GatheringThe Art and Science of Requirements Gathering
The Art and Science of Requirements Gathering
 
Object Oriented System Design
Object Oriented System DesignObject Oriented System Design
Object Oriented System Design
 
Chapter 1 intr m dfina
Chapter 1 intr m dfinaChapter 1 intr m dfina
Chapter 1 intr m dfina
 
The company which asked you to install a web server and properly s.docx
The company which asked you to install a web server and properly s.docxThe company which asked you to install a web server and properly s.docx
The company which asked you to install a web server and properly s.docx
 
Designing and documenting software architecture unit 5
Designing and documenting software architecture unit 5Designing and documenting software architecture unit 5
Designing and documenting software architecture unit 5
 
Chapter 3.pptx
Chapter 3.pptxChapter 3.pptx
Chapter 3.pptx
 
Recsys 2016
Recsys 2016Recsys 2016
Recsys 2016
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Chapter 1 intr m dfina
Chapter 1 intr m dfinaChapter 1 intr m dfina
Chapter 1 intr m dfina
 
11 - Evaluating Framework in Interaction Design_new.pptx
11 - Evaluating Framework in Interaction Design_new.pptx11 - Evaluating Framework in Interaction Design_new.pptx
11 - Evaluating Framework in Interaction Design_new.pptx
 
03 Analyzing The Problem
03 Analyzing The Problem03 Analyzing The Problem
03 Analyzing The Problem
 
Advanced Software Engineering.ppt
Advanced Software Engineering.pptAdvanced Software Engineering.ppt
Advanced Software Engineering.ppt
 

Kürzlich hochgeladen

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 

Kürzlich hochgeladen (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

Concerns and Presenters in Rails

  • 1. Concerns and Presenters By - Aaditi Jain
  • 5. Concern : Dependency Methods of a concern are not invoked until the concern is included in something that is not a concern.
  • 6. Concerns in Models : DRYing Example : Consider a Article model, a Event model and a Comment Model. An article or an event has_many comments. A comment belongs_to either article or event.
  • 9. Concerns in Models : Modularization Example : Consider a Event model. A event has many attenders and comments. Typically, the event model might look like this:
  • 10. Concerns in Models : Modularization
  • 11. Concerns In Controllers : Modularization and DRYing Concerns can be used in Controllers in a similar way as in Models. Example: • An Users controller, an Articles Controller, an Events Controller. • A User has to login to view all the articles and events . • Typically: Both Articles and Events controller will have some logic to check that the user has logged in etc. • Concerns : Shift all the common logic related to user in Article and Event controller into a concern module called Authorizable. Then Include this Authorizable module in Articles and Events Controller.
  • 12. Concerns: Placement and Logic Placement • If only one concern per model/controller or One concern is being included by multiple models/controllers: Place them directly under the concerns folder. app/controller/concern/authorizable.rb app/model/concern/commentable.rb • If many concerns per model/controller: Create a folder inside the concerns with the name of the model/controller and place them inside it. app/model/event/attendable.rb Logic: Concerns should be domain based rather than technical based. For Example : For a model, domain based concerns will be like ‘Commentable’, ‘Taggable’, While technical based concerns will be ‘FinderMethod’, ‘ValidationMethod’
  • 13. Concerns: Pros and Cons Pros • Easy to Use for refactoring. • No external dependency Cons • Modules Problem • Debugging is tougher • No actual reduction in code. Its just better organized.
  • 15. Example : Consider an application with this setup :
  • 16. Problems With this Approach • Multiple Instance Variables in Controllers : 1) Violation Of Sandi Metz Rule : One Controller action may pass only one instance variable to its corresponding view. 2) Seperation of Concern in Controllers • Logic creeping In the view files Solutions : Include Logic as Models Methods Include Logic in Helpers
  • 17. Presenters : A Design Pattern
  • 18. Presenters : A Design Pattern Create a folder in your app directory with name ‘presenters’. Create a .rb file specific to the model we are working with (user in our case)
  • 19. Presenters : A Design Pattern
  • 20. Presenters Pros and Cons Pros • Introduces Object-Oriented-ness in the View Layer • Clean Controllers and Views • Easy Testing. Cons • Generating this additional layer is a overhead.
  • 22. References • https://github.com/justin808/fat-code-refactoring-techniques • http://railscasts.com/episodes/287-presenters-from-scratch • http://sokolmichael.com/posts/2012-01-14-model-view- controller-presenter-better-separation-of-concern • https://www.youtube.com/watch?v=VC5z8nadnQE