SlideShare une entreprise Scribd logo
1  sur  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

Contenu connexe

En vedette

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
 

En vedette (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
 

Similaire à 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
 
457 WWDC08 Student Welcome
457 WWDC08 Student Welcome457 WWDC08 Student Welcome
457 WWDC08 Student Welcomerentzsch
 
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
 

Similaire à 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
 
457 WWDC08 Student Welcome
457 WWDC08 Student Welcome457 WWDC08 Student Welcome
457 WWDC08 Student Welcome
 
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
 

Dernier

New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 

Dernier (20)

New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 

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

Notes de l'éditeur