SlideShare ist ein Scribd-Unternehmen logo
1 von 41
Catalyst & Chained

                             MVC
                           Bondage
Friday, February 6, 2009
Catalyst & Chained



                           Jay Shirley: ‘jshirley’

                      •Director, National Auto Sport Assoc.
                      •Business Director, Cold Hard Code
                      •Catalyst, DBIx::Class
                      •http://our.coldhardcode.com/jshirley/
                      •JAPH

Friday, February 6, 2009
Catalyst & Chained




                                  What is
         Catalyst?
Friday, February 6, 2009
Catalyst & Chained




                  What Catalyst
                           Is Not.
Friday, February 6, 2009
Catalyst & Chained



                           What Catalyst Is Not

                      •An experiment or prototype.
                      •A toy.
                      •Opinionated.
                      •An “all in one” package.
                      •Complicated.

Friday, February 6, 2009
Catalyst & Chained



                             What Catalyst Is

                      •Simple Framework.
                      •Trusts the developer.
                      •Buckets.
                      •Easily extensible.

Friday, February 6, 2009
Catalyst & Chained



                                  The Basics

                      •MVC Oriented.
                      •Promotes good code design.
                      •Use all of CPAN, easily.
                      •Built-in server.

Friday, February 6, 2009
Catalyst & Chained



                                  Dispatching
                      •Getting from here to there
                      •/public/url => /private/action
                      •Types:
                       •Chained
                       •Local
                       •Regular Expressions
Friday, February 6, 2009
Catalyst & Chained




                                  What is
                Chained?
Friday, February 6, 2009
Catalyst & Chained



                           Chained in 4 Sentences

                      •Defined execution path
                      •“Route” of methods to take
                      •Configurable URLs
                      •Spans Multiple Controllers

Friday, February 6, 2009
Catalyst & Chained



                                   In Code:


                           sub base { }
                           sub after_base { }
                           sub after_after_base { }


Friday, February 6, 2009
Catalyst & Chained: 999 Words



                           In Pictures (and code)

                                  A              B              display




                                       Private Path: /a/b/end

       sub A : Chained(‘/’) CaptureArgs(0){}
       sub B : Chained(‘A’) CaptureArgs(0){}

       sub display : Chained(‘B’) Args(0){}
Friday, February 6, 2009
Catalyst & Chained



                              What’s the point?

                      •Public URI != Internal Actions
                      •Easily add “automatic” code
                           (no more sub auto { })
                      •Each step is executed, in order.
                      •Can capture URI arguments
Friday, February 6, 2009
Catalyst & Chained: If you know mst, you know it isn’t a...



                                      Free Lunch
                      •Short-circuit any request at any
                           point.
                      •Easily add midpoint actions.
                      •Descend namespaces.
                      •Sane and programmatic URI
                           construction.
                      •Easy abstraction.
Friday, February 6, 2009
Catalyst & Chained




                       Benefits

Friday, February 6, 2009
Catalyst & Chained



                              Configurable URLs
                 •Public Paths:
                            PathPart(‘public_url_part’)
                 •Internal Action:
                            sub action_name : ... { }


                 •Easily modifiable public paths to change
                           URL structure.

Friday, February 6, 2009
Catalyst & Chained: Your own personal Voltron



                              Configurable Paths
                           __PACKAGE__->config(
                            action => {
                             ‘action_name’ => {
                               Chained => ‘/’,
                               PathPart(‘public’)
                             }
                            }
                           ); # Public URL: /public
Friday, February 6, 2009
Catalyst & Chained



                                  Why?


                 •Public URLs are your API
                 •Being able to change them is good.
                 •Not breaking them is better.


Friday, February 6, 2009
Catalyst & Chained



                                  Abstraction



         package MyApp::ControllerBase::Foo;




Friday, February 6, 2009
Catalyst & Chained: Pass the cool whip



                           Thinner Controllers

         package MyApp::Controller::Bar;
         use parent ‘MyApp::ControllerBase::Foo’;

         sub setup : Chained(‘.’) CaptureArgs(0) {
           # Setup stash, done!
         }


Friday, February 6, 2009
Catalyst & Chained: Pass the cool whip



                           Thinner Controllers

         package MyApp::Controller::Bar;
         use parent ‘MyApp::ControllerBase::Foo’;

         sub setup : Chained(‘.’) CaptureArgs(0) {
           # Setup stash, done!
         }


Friday, February 6, 2009
Catalyst & Chained



                           Common End-Points

         package MyApp::ControllerBase::Foo;
         use parent ‘Catalyst::Controller’;

         sub display : Chained(‘...’) Args(0) {
         }



Friday, February 6, 2009
Catalyst & Chained




                                  Better
         Applications

Friday, February 6, 2009
Catalyst & Chained



                           A Simple Example


                      •Photos
                       •Belong to a ‘person’
                       •Have tags


Friday, February 6, 2009
Catalyst & Chained



                                  URL Structure


                      •Keep it simple:
                       •/person/$name/photos
                       •/tag/$name/photos


Friday, February 6, 2009
Catalyst & Chained



                                  Controllers

                      •MyApp::Controller::Person
                       •MyApp::Controller::Person::Photos
                      •MyApp::Controller::Tag
                       •MyApp::Controller::Tag::Photos

Friday, February 6, 2009
Catalyst & Chained



                              Commonalities

                      •MyApp::Controller::Person
                       •MyApp::Controller::Person::Photos
                      •MyApp::Controller::Tag
                       •MyApp::Controller::Tag::Photos

Friday, February 6, 2009
Catalyst & Chained



                                  The Base Class
         package MyApp::ControllerBase::Photos;
         use parent ‘Catalyst::Controller’;

         sub display : Chained(‘setup’)
                 PathPart(‘photos’) Args(0)
         {
         }

Friday, February 6, 2009
Catalyst & Chained



                                  The Base Class
         package MyApp::ControllerBase::Photos;
         use parent ‘Catalyst::Controller’;

         sub display : Chained(‘setup’)
                 PathPart(‘photos’) Args(0)
         {
         }

Friday, February 6, 2009
Catalyst & Chained



                                  The Base Class
         package MyApp::ControllerBase::Photos;
         use parent ‘Catalyst::Controller’;

         sub display : Chained(‘setup’)
                 PathPart(‘photos’) Args(0)
         {
         }

Friday, February 6, 2009
Catalyst & Chained



                                  Person::Photos
         package MyApp::Controller::Person::Photos;
         use parent ‘MyApp::ControllerBase::Photos’;

         sub setup : Chained(‘.’) PathPart(‘’)
                CaptureArgs(0)
         {
           my ( $self, $c ) = @_;
           $c->stash->{photos} =
             $c->stash->{person}->photos;
         }

Friday, February 6, 2009
Catalyst & Chained



                                  Person::Photos
         package MyApp::Controller::Person::Photos;
         use parent ‘MyApp::ControllerBase::Photos’;

         sub setup : Chained(‘.’) PathPart(‘’)
                CaptureArgs(0)
         {
           my ( $self, $c ) = @_;
           $c->stash->{photos} =
             $c->stash->{person}->photos;
         }

Friday, February 6, 2009
Catalyst & Chained



                                  Person::Photos
         package MyApp::Controller::Person::Photos;
         use parent ‘MyApp::ControllerBase::Photos’;

         sub setup : Chained(‘.’) PathPart(‘’)
                CaptureArgs(0)
         {
           my ( $self, $c ) = @_;
           $c->stash->{photos} =
             $c->stash->{person}->photos;
         }

Friday, February 6, 2009
Catalyst & Chained



                                       A Note

                           •Person::Photos only:
                            •cares about itself.
                            •is very thin (just the stash, ma’am).
                            •can actually be abstracted to just
                               configuration



Friday, February 6, 2009
Catalyst & Chained



                                   Tag::Photos


                           •Same as Person::Photos, except:
                            •$c->stash->{tag} instead of
                              $c->stash->{person}
                            •has a different template.

Friday, February 6, 2009
Catalyst & Chained



                    The Base Class, Version 2
         package MyApp::ControllerBase::Photos;
         use parent ‘Catalyst::Controller’;

         sub setup : Chained(‘.’) PathPart(‘’) CaptureArgs(0) {
           my ( $self, $c ) = @_;
           my $stash = $self->{stash_key};
           my $source = $self->{source_key};
           $c->stash->{$stash} = $c->stash->{$source}->photos;
         }

         sub display ... { # unchanged }

Friday, February 6, 2009
Catalyst & Chained



                                  Config: Person

         package MyApp::Controller::Person::Photos;
         use parent ‘MyApp::ControllerBase::Photos’;

         __PACKAGE__->config(
            source_key => ‘person’,
            stash_key => ‘photos’
         );


Friday, February 6, 2009
Catalyst & Chained



                                  Config: Tag

         package MyApp::Controller::Tag::Photos;
         use parent ‘MyApp::ControllerBase::Photos’;

         __PACKAGE__->config(
            source_key => ‘tag’,
            stash_key => ‘photos’
         );


Friday, February 6, 2009
Catalyst & Chained



                                  Config: Tag

         package MyApp::Controller::Tag::Photos;
         use parent ‘MyApp::ControllerBase::Photos’;

         __PACKAGE__->config(
            source_key => ‘tag’,
            stash_key => ‘photos’
         );


Friday, February 6, 2009
Catalyst & Chained



                                      That’s it

                           •Now, you just work with:
                            •/person/photos/display.tt
                            •/tag/photos/display.tt
                           •Thin controllers, how to get photos
                             determined just from configuration.



Friday, February 6, 2009
Catalyst & Chained




 Questions?
    http://github.com/jshirley/catalystx-example-chained/tree




Friday, February 6, 2009

Weitere ähnliche Inhalte

Andere mochten auch

Assess2012 technology trends
Assess2012 technology trendsAssess2012 technology trends
Assess2012 technology trendsiansyst
 
Getting started with Catalyst and extjs
Getting started with Catalyst and extjsGetting started with Catalyst and extjs
Getting started with Catalyst and extjsPeter Edwards
 
Advanced modulinos trial
Advanced modulinos trialAdvanced modulinos trial
Advanced modulinos trialbrian d foy
 
Advanced modulinos
Advanced modulinosAdvanced modulinos
Advanced modulinosbrian d foy
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalystdwm042
 

Andere mochten auch (7)

Assess2012 technology trends
Assess2012 technology trendsAssess2012 technology trends
Assess2012 technology trends
 
Apps mit Flash Catalyst
Apps mit Flash CatalystApps mit Flash Catalyst
Apps mit Flash Catalyst
 
Getting started with Catalyst and extjs
Getting started with Catalyst and extjsGetting started with Catalyst and extjs
Getting started with Catalyst and extjs
 
Dancing Tutorial
Dancing TutorialDancing Tutorial
Dancing Tutorial
 
Advanced modulinos trial
Advanced modulinos trialAdvanced modulinos trial
Advanced modulinos trial
 
Advanced modulinos
Advanced modulinosAdvanced modulinos
Advanced modulinos
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalyst
 

Ähnlich wie Catalyst And Chained

MacRuby - When objective-c and Ruby meet
MacRuby - When objective-c and Ruby meetMacRuby - When objective-c and Ruby meet
MacRuby - When objective-c and Ruby meetMatt Aimonetti
 
No Really, It's All About You
No Really, It's All About YouNo Really, It's All About You
No Really, It's All About YouChris Cornutt
 
Railswaycon 2009 - Summary
Railswaycon 2009 - SummaryRailswaycon 2009 - Summary
Railswaycon 2009 - Summarydaniel.mattes
 
Oxente on Rails 2009
Oxente on Rails 2009Oxente on Rails 2009
Oxente on Rails 2009Fabio Akita
 
Advanced App Building - Tips, Tricks & Lessons Learned
Advanced App Building - Tips, Tricks & Lessons LearnedAdvanced App Building - Tips, Tricks & Lessons Learned
Advanced App Building - Tips, Tricks & Lessons LearnedJay Graves
 
Administrivia: Golden Tips for Making JIRA Hum
Administrivia: Golden Tips for Making JIRA HumAdministrivia: Golden Tips for Making JIRA Hum
Administrivia: Golden Tips for Making JIRA HumAtlassian
 
Administrivia: Golden Tips for Making JIRA Hum
Administrivia: Golden Tips for Making JIRA HumAdministrivia: Golden Tips for Making JIRA Hum
Administrivia: Golden Tips for Making JIRA HumAtlassian
 
Enterprise Security mit Spring Security
Enterprise Security mit Spring SecurityEnterprise Security mit Spring Security
Enterprise Security mit Spring SecurityMike Wiesner
 
Improving Drupal's Page Loading Performance
Improving Drupal's Page Loading PerformanceImproving Drupal's Page Loading Performance
Improving Drupal's Page Loading PerformanceWim Leers
 
Joomla Template Development
Joomla Template DevelopmentJoomla Template Development
Joomla Template DevelopmentLinda Coonen
 
Web Standards and Accessibility
Web Standards and AccessibilityWeb Standards and Accessibility
Web Standards and AccessibilityNick DeNardis
 
Apache Solr Changes the Way You Build Sites
Apache Solr Changes the Way You Build SitesApache Solr Changes the Way You Build Sites
Apache Solr Changes the Way You Build SitesPeter
 
Ryan Campbell - OpenFlux and Flex 4
Ryan Campbell - OpenFlux and Flex 4Ryan Campbell - OpenFlux and Flex 4
Ryan Campbell - OpenFlux and Flex 4360|Conferences
 
Bay Area Drupal Camp Efficiency
Bay Area Drupal Camp EfficiencyBay Area Drupal Camp Efficiency
Bay Area Drupal Camp Efficiencysmattoon
 
Talking About Fluent Interface
Talking About Fluent InterfaceTalking About Fluent Interface
Talking About Fluent InterfaceKoji SHIMADA
 
Portlets
PortletsPortlets
Portletsssetem
 
Creating Practical Security Test-Cases for Web Applications
Creating Practical Security Test-Cases for Web ApplicationsCreating Practical Security Test-Cases for Web Applications
Creating Practical Security Test-Cases for Web ApplicationsRafal Los
 
Deploying And Monitoring Rails
Deploying And Monitoring RailsDeploying And Monitoring Rails
Deploying And Monitoring RailsJonathan Weiss
 

Ähnlich wie Catalyst And Chained (20)

MacRuby - When objective-c and Ruby meet
MacRuby - When objective-c and Ruby meetMacRuby - When objective-c and Ruby meet
MacRuby - When objective-c and Ruby meet
 
All The Little Pieces
All The Little PiecesAll The Little Pieces
All The Little Pieces
 
No Really, It's All About You
No Really, It's All About YouNo Really, It's All About You
No Really, It's All About You
 
Railswaycon 2009 - Summary
Railswaycon 2009 - SummaryRailswaycon 2009 - Summary
Railswaycon 2009 - Summary
 
Oxente on Rails 2009
Oxente on Rails 2009Oxente on Rails 2009
Oxente on Rails 2009
 
Advanced App Building - Tips, Tricks & Lessons Learned
Advanced App Building - Tips, Tricks & Lessons LearnedAdvanced App Building - Tips, Tricks & Lessons Learned
Advanced App Building - Tips, Tricks & Lessons Learned
 
Administrivia: Golden Tips for Making JIRA Hum
Administrivia: Golden Tips for Making JIRA HumAdministrivia: Golden Tips for Making JIRA Hum
Administrivia: Golden Tips for Making JIRA Hum
 
Administrivia: Golden Tips for Making JIRA Hum
Administrivia: Golden Tips for Making JIRA HumAdministrivia: Golden Tips for Making JIRA Hum
Administrivia: Golden Tips for Making JIRA Hum
 
Enterprise Security mit Spring Security
Enterprise Security mit Spring SecurityEnterprise Security mit Spring Security
Enterprise Security mit Spring Security
 
Improving Drupal's Page Loading Performance
Improving Drupal's Page Loading PerformanceImproving Drupal's Page Loading Performance
Improving Drupal's Page Loading Performance
 
Joomla Template Development
Joomla Template DevelopmentJoomla Template Development
Joomla Template Development
 
Web Standards and Accessibility
Web Standards and AccessibilityWeb Standards and Accessibility
Web Standards and Accessibility
 
Apache Solr Changes the Way You Build Sites
Apache Solr Changes the Way You Build SitesApache Solr Changes the Way You Build Sites
Apache Solr Changes the Way You Build Sites
 
Ryan Campbell - OpenFlux and Flex 4
Ryan Campbell - OpenFlux and Flex 4Ryan Campbell - OpenFlux and Flex 4
Ryan Campbell - OpenFlux and Flex 4
 
Bay Area Drupal Camp Efficiency
Bay Area Drupal Camp EfficiencyBay Area Drupal Camp Efficiency
Bay Area Drupal Camp Efficiency
 
Intro To Git
Intro To GitIntro To Git
Intro To Git
 
Talking About Fluent Interface
Talking About Fluent InterfaceTalking About Fluent Interface
Talking About Fluent Interface
 
Portlets
PortletsPortlets
Portlets
 
Creating Practical Security Test-Cases for Web Applications
Creating Practical Security Test-Cases for Web ApplicationsCreating Practical Security Test-Cases for Web Applications
Creating Practical Security Test-Cases for Web Applications
 
Deploying And Monitoring Rails
Deploying And Monitoring RailsDeploying And Monitoring Rails
Deploying And Monitoring Rails
 

Kürzlich hochgeladen

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
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
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
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
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
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
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
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
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
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
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 

Kürzlich hochgeladen (20)

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
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
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
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
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
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
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
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?
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
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
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 

Catalyst And Chained

  • 1. Catalyst & Chained MVC Bondage Friday, February 6, 2009
  • 2. Catalyst & Chained Jay Shirley: ‘jshirley’ •Director, National Auto Sport Assoc. •Business Director, Cold Hard Code •Catalyst, DBIx::Class •http://our.coldhardcode.com/jshirley/ •JAPH Friday, February 6, 2009
  • 3. Catalyst & Chained What is Catalyst? Friday, February 6, 2009
  • 4. Catalyst & Chained What Catalyst Is Not. Friday, February 6, 2009
  • 5. Catalyst & Chained What Catalyst Is Not •An experiment or prototype. •A toy. •Opinionated. •An “all in one” package. •Complicated. Friday, February 6, 2009
  • 6. Catalyst & Chained What Catalyst Is •Simple Framework. •Trusts the developer. •Buckets. •Easily extensible. Friday, February 6, 2009
  • 7. Catalyst & Chained The Basics •MVC Oriented. •Promotes good code design. •Use all of CPAN, easily. •Built-in server. Friday, February 6, 2009
  • 8. Catalyst & Chained Dispatching •Getting from here to there •/public/url => /private/action •Types: •Chained •Local •Regular Expressions Friday, February 6, 2009
  • 9. Catalyst & Chained What is Chained? Friday, February 6, 2009
  • 10. Catalyst & Chained Chained in 4 Sentences •Defined execution path •“Route” of methods to take •Configurable URLs •Spans Multiple Controllers Friday, February 6, 2009
  • 11. Catalyst & Chained In Code: sub base { } sub after_base { } sub after_after_base { } Friday, February 6, 2009
  • 12. Catalyst & Chained: 999 Words In Pictures (and code) A B display Private Path: /a/b/end sub A : Chained(‘/’) CaptureArgs(0){} sub B : Chained(‘A’) CaptureArgs(0){} sub display : Chained(‘B’) Args(0){} Friday, February 6, 2009
  • 13. Catalyst & Chained What’s the point? •Public URI != Internal Actions •Easily add “automatic” code (no more sub auto { }) •Each step is executed, in order. •Can capture URI arguments Friday, February 6, 2009
  • 14. Catalyst & Chained: If you know mst, you know it isn’t a... Free Lunch •Short-circuit any request at any point. •Easily add midpoint actions. •Descend namespaces. •Sane and programmatic URI construction. •Easy abstraction. Friday, February 6, 2009
  • 15. Catalyst & Chained Benefits Friday, February 6, 2009
  • 16. Catalyst & Chained Configurable URLs •Public Paths: PathPart(‘public_url_part’) •Internal Action: sub action_name : ... { } •Easily modifiable public paths to change URL structure. Friday, February 6, 2009
  • 17. Catalyst & Chained: Your own personal Voltron Configurable Paths __PACKAGE__->config( action => { ‘action_name’ => { Chained => ‘/’, PathPart(‘public’) } } ); # Public URL: /public Friday, February 6, 2009
  • 18. Catalyst & Chained Why? •Public URLs are your API •Being able to change them is good. •Not breaking them is better. Friday, February 6, 2009
  • 19. Catalyst & Chained Abstraction package MyApp::ControllerBase::Foo; Friday, February 6, 2009
  • 20. Catalyst & Chained: Pass the cool whip Thinner Controllers package MyApp::Controller::Bar; use parent ‘MyApp::ControllerBase::Foo’; sub setup : Chained(‘.’) CaptureArgs(0) { # Setup stash, done! } Friday, February 6, 2009
  • 21. Catalyst & Chained: Pass the cool whip Thinner Controllers package MyApp::Controller::Bar; use parent ‘MyApp::ControllerBase::Foo’; sub setup : Chained(‘.’) CaptureArgs(0) { # Setup stash, done! } Friday, February 6, 2009
  • 22. Catalyst & Chained Common End-Points package MyApp::ControllerBase::Foo; use parent ‘Catalyst::Controller’; sub display : Chained(‘...’) Args(0) { } Friday, February 6, 2009
  • 23. Catalyst & Chained Better Applications Friday, February 6, 2009
  • 24. Catalyst & Chained A Simple Example •Photos •Belong to a ‘person’ •Have tags Friday, February 6, 2009
  • 25. Catalyst & Chained URL Structure •Keep it simple: •/person/$name/photos •/tag/$name/photos Friday, February 6, 2009
  • 26. Catalyst & Chained Controllers •MyApp::Controller::Person •MyApp::Controller::Person::Photos •MyApp::Controller::Tag •MyApp::Controller::Tag::Photos Friday, February 6, 2009
  • 27. Catalyst & Chained Commonalities •MyApp::Controller::Person •MyApp::Controller::Person::Photos •MyApp::Controller::Tag •MyApp::Controller::Tag::Photos Friday, February 6, 2009
  • 28. Catalyst & Chained The Base Class package MyApp::ControllerBase::Photos; use parent ‘Catalyst::Controller’; sub display : Chained(‘setup’) PathPart(‘photos’) Args(0) { } Friday, February 6, 2009
  • 29. Catalyst & Chained The Base Class package MyApp::ControllerBase::Photos; use parent ‘Catalyst::Controller’; sub display : Chained(‘setup’) PathPart(‘photos’) Args(0) { } Friday, February 6, 2009
  • 30. Catalyst & Chained The Base Class package MyApp::ControllerBase::Photos; use parent ‘Catalyst::Controller’; sub display : Chained(‘setup’) PathPart(‘photos’) Args(0) { } Friday, February 6, 2009
  • 31. Catalyst & Chained Person::Photos package MyApp::Controller::Person::Photos; use parent ‘MyApp::ControllerBase::Photos’; sub setup : Chained(‘.’) PathPart(‘’) CaptureArgs(0) { my ( $self, $c ) = @_; $c->stash->{photos} = $c->stash->{person}->photos; } Friday, February 6, 2009
  • 32. Catalyst & Chained Person::Photos package MyApp::Controller::Person::Photos; use parent ‘MyApp::ControllerBase::Photos’; sub setup : Chained(‘.’) PathPart(‘’) CaptureArgs(0) { my ( $self, $c ) = @_; $c->stash->{photos} = $c->stash->{person}->photos; } Friday, February 6, 2009
  • 33. Catalyst & Chained Person::Photos package MyApp::Controller::Person::Photos; use parent ‘MyApp::ControllerBase::Photos’; sub setup : Chained(‘.’) PathPart(‘’) CaptureArgs(0) { my ( $self, $c ) = @_; $c->stash->{photos} = $c->stash->{person}->photos; } Friday, February 6, 2009
  • 34. Catalyst & Chained A Note •Person::Photos only: •cares about itself. •is very thin (just the stash, ma’am). •can actually be abstracted to just configuration Friday, February 6, 2009
  • 35. Catalyst & Chained Tag::Photos •Same as Person::Photos, except: •$c->stash->{tag} instead of $c->stash->{person} •has a different template. Friday, February 6, 2009
  • 36. Catalyst & Chained The Base Class, Version 2 package MyApp::ControllerBase::Photos; use parent ‘Catalyst::Controller’; sub setup : Chained(‘.’) PathPart(‘’) CaptureArgs(0) { my ( $self, $c ) = @_; my $stash = $self->{stash_key}; my $source = $self->{source_key}; $c->stash->{$stash} = $c->stash->{$source}->photos; } sub display ... { # unchanged } Friday, February 6, 2009
  • 37. Catalyst & Chained Config: Person package MyApp::Controller::Person::Photos; use parent ‘MyApp::ControllerBase::Photos’; __PACKAGE__->config( source_key => ‘person’, stash_key => ‘photos’ ); Friday, February 6, 2009
  • 38. Catalyst & Chained Config: Tag package MyApp::Controller::Tag::Photos; use parent ‘MyApp::ControllerBase::Photos’; __PACKAGE__->config( source_key => ‘tag’, stash_key => ‘photos’ ); Friday, February 6, 2009
  • 39. Catalyst & Chained Config: Tag package MyApp::Controller::Tag::Photos; use parent ‘MyApp::ControllerBase::Photos’; __PACKAGE__->config( source_key => ‘tag’, stash_key => ‘photos’ ); Friday, February 6, 2009
  • 40. Catalyst & Chained That’s it •Now, you just work with: •/person/photos/display.tt •/tag/photos/display.tt •Thin controllers, how to get photos determined just from configuration. Friday, February 6, 2009
  • 41. Catalyst & Chained Questions? http://github.com/jshirley/catalystx-example-chained/tree Friday, February 6, 2009

Hinweis der Redaktion