SlideShare a Scribd company logo
1 of 40
Download to read offline
Robert Lemke
Create Clean Code with Aspect-Oriented Programming
WebExpo 2010, Prague




                                             Photo: Robert Szlivka
Robert Lemke
chief architect of TYPO3 Phoenix and FLOW3

co-founder of the TYPO3 Association

34 years old

lives in Lübeck, Germany

1 wife, 1 daughter, 1 espresso machine

likes drumming
www.typo3.org
www.typo3.org
www.typo3.org




   Create Clean Code with AOP   WebExpo 2010, Prague
= PHP 5.3 Full Stack Application Framework
DI   Dependency Injection              DRY
                                                       YAA
                             OOP   Object-Oriented Programming
YAGNI
               AOP Aspect-Oriented Programming
 CoC
                             MVC   Model View Controller


      POPO Plain Old PHP Object                      TDD
/**
  * Creates a new post
  *
  * @param F3BlogDomainModelPost $newPost A fresh Post object which has not yet been
  *                                                               added to the repository
  * @return void
  */
public function createAction(F3BlogDomainModelPost $newPost) {
     if ($this->policyService->isGranted($this->currentUser, __CLASS__, __METHOD__) {
         $this->blog->addPost($newPost);
         $this->flashMessageContainer->add('Your new post was created.');
         $this->systemLogger->log('A new post was created.', LOG_INFO);
         $this->notificationService->notify('A new post was created.', 'robert@typo3.org');
     } else {
         $this->systemLogger->log('Someone tried to create a post.', LOG_WARNING);
         throw new F3FLOW3SecurityExceptionAccessDeniedException('Tried to create.');
     }
     $this->redirect('index');
}


    Create Clean Code with AOP                                          WebExpo 2010, Prague
/**
  * Creates a new post
  *
  * @param F3BlogDomainModelPost $newPost A fresh Post object which has not yet been
  *                                                               added to the repository
  * @return void
  */
public function createAction(F3BlogDomainModelPost $newPost) {
     if ($this->policyService->isGranted($this->currentUser, __CLASS__, __METHOD__) {
         $this->blog->addPost($newPost);
         $this->flashMessageContainer->add('Your new post was created.');
         $this->systemLogger->log('A new post was created.', LOG_INFO);
         $this->notificationService->notify('A new post was created.', 'robert@typo3.org');
     } else {
         $this->systemLogger->log('Someone tried to create a post.', LOG_WARNING);
         throw new F3FLOW3SecurityExceptionAccessDeniedException('Tried to create.');
     }
     $this->redirect('index');
}


    Create Clean Code with AOP                                          WebExpo 2010, Prague
Create Clean Code with AOP   WebExpo 2010, Prague
AOP
Create Clean Code with AOP   WebExpo 2010, Prague
Aspect-Oriented Programming
       programming paradigm

       separates concerns to improve modularization


       OOP modularizes concerns into objects

       AOP modularizes cross-cutting concerns into aspects




Create Clean Code with AOP                                   WebExpo 2010, Prague
/**
  * Creates a new post
  *
  * @param F3BlogDomainModelPost $newPost A fresh Post object which has not yet been
  *                                            added to the repository
  * @return void
  */
public function createAction(F3BlogDomainModelPost $newPost) {
     $this->blog->addPost($newPost);
     $this->flashMessageContainer->add('Your new post was created.');
     $this->redirect('index');
}




    Create Clean Code with AOP                                     WebExpo 2010, Prague
Concerns?
Create Clean Code with AOP   WebExpo 2010, Prague
Concerns
       Separation of Concerns

          group features and behavior into manageable parts

          have a specific purpose and business to take care of

       Cross-Cutting Concerns

          are the party poopers who want to have a say in everything




Create Clean Code with AOP                                         WebExpo 2010, Prague
Cross-Cutting Concerns
       Logging

       Security

       Persistence

       Global Business Logic

       Dirty Hacks




Create Clean Code with AOP     WebExpo 2010, Prague
We don't want infrastructure code
in our models.




Create Clean Code with AOP          WebExpo 2010, Prague
We want to unit-test even
cross-cutting concerns




Create Clean Code with AOP   WebExpo 2010, Prague
We want to centralize
security-related code




Create Clean Code with AOP   WebExpo 2010, Prague
AOP Lingo


Create Clean Code with AOP   WebExpo 2010, Prague
Aspect
       Part of the application where cross-cutting concerns are implemented

       In FLOW3 aspects are classes annotated with @aspect




Create Clean Code with AOP                                        WebExpo 2010, Prague
Join Point
       Is a single point in the call graph

          Method Execution

          Exception

       Represents an event, not a location




Create Clean Code with AOP                   WebExpo 2010, Prague
Pointcut
       A set of join points where advices could be executed

          can be composed

          can be named




Create Clean Code with AOP                                    WebExpo 2010, Prague
Advice
       Action to take at a join points defined by the point cut




Create Clean Code with AOP                                       WebExpo 2010, Prague
DEMO
                              Inspiring people to
Hitchhiker's Guide to FLOW3   share
Kinds of Advice
Advice types supported by FLOW3:

@before
@afterreturning
@afterthrowing
@after
@around




                                   Inspiring people to
Hitchhiker's Guide to FLOW3        share
Pointcut Designators
method(F3MyPackageMyClass->myMethod())
class(F3MyPackageMyClass)
within(F3MyPackageMyInterface)
classTaggedWith(someTag)
methodTaggedWith(anotherTag)
setting(Demo.Stuff.SomeSetting = "yeah, do it")
filter(F3MyPackageMyCustomFilterImplementation)
 fi




                                          Inspiring people to
Hitchhiker's Guide to FLOW3               share
Runtime Evaluations
evaluate(coffee.kind == "Arabica")




                                     Inspiring people to
Hitchhiker's Guide to FLOW3          share
Compound Pointcuts
!   /**
!    * @around method(.*Controller->(new|create|edit|update|delete)Action()) && 
       !methodTaggedWith(anybodyMayAccessThis)
!    */
!   public function interceptMethodCalls($joinPoint) {
       ...
    }




                                                           Inspiring people to
        Hitchhiker's Guide to FLOW3                        share
DEMO
                              Inspiring people to
Hitchhiker's Guide to FLOW3   share
FLOW3's AOP implementation
     based on proxy classes

       unlike with most pre-processors line numbers stay the same

     no scaffolding

       0 Lines of generated code which need to be maintained by you

     fast (on the second hit)




                                                                Inspiring people to
Hitchhiker's Guide to FLOW3                                     share
Inspiring people to
Hitchhiker's Guide to FLOW3   share
Inspiring people to
Hitchhiker's Guide to FLOW3   share
Progress

                   FLOW3 1.0.0




Create Clean Code with AOP       WebExpo 2010, Prague
Further Reading
       FLOW3 Website
       http://flow3.typo3.org

       FLOW3 Download
       http://flow3.typo3.org/download
       git://git.typo3.org/FLOW3/Distributions/Base.git

       TYPO3 Forge
       http://forge.typo3.org

       Further Reading
       http://flow3.typo3.org/about/principles/further-reading



Create Clean Code with AOP                                      WebExpo 2010, Prague
Questions

Email:             robert@typo3.org
Blog:              http://robertlemke.de/blog
Twitter:           @t3rob

Slides:            http://slideshare.net/rlmp




Create Clean Code with AOP                      WebExpo 2010, Prague
Create Clean Code with AOP at WebExpo 2010

More Related Content

What's hot

クリーンアーキテクチャの考え方にもとづく Laravel との付き合い方 #phpcondo
クリーンアーキテクチャの考え方にもとづく Laravel との付き合い方 #phpcondoクリーンアーキテクチャの考え方にもとづく Laravel との付き合い方 #phpcondo
クリーンアーキテクチャの考え方にもとづく Laravel との付き合い方 #phpcondoShohei Okada
 
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterSymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterHaehnchen
 
LvivPy - Flask in details
LvivPy - Flask in detailsLvivPy - Flask in details
LvivPy - Flask in detailsMax Klymyshyn
 
Python/Flask Presentation
Python/Flask PresentationPython/Flask Presentation
Python/Flask PresentationParag Mujumdar
 
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...Edureka!
 
Build restful ap is with python and flask
Build restful ap is with python and flaskBuild restful ap is with python and flask
Build restful ap is with python and flaskJeetendra singh
 
Web develop in flask
Web develop in flaskWeb develop in flask
Web develop in flaskJim Yeh
 
Cis407 a ilab 4 web application development devry university
Cis407 a ilab 4 web application development devry universityCis407 a ilab 4 web application development devry university
Cis407 a ilab 4 web application development devry universitylhkslkdh89009
 
Willow, the interaction tour
Willow, the interaction tourWillow, the interaction tour
Willow, the interaction tourESUG
 
Quick flask an intro to flask
Quick flask   an intro to flaskQuick flask   an intro to flask
Quick flask an intro to flaskjuzten
 
Flask patterns
Flask patternsFlask patterns
Flask patternsit-people
 
What The Flask? and how to use it with some Google APIs
What The Flask? and how to use it with some Google APIsWhat The Flask? and how to use it with some Google APIs
What The Flask? and how to use it with some Google APIsBruno Rocha
 
Hands-on with the Symfony2 Framework
Hands-on with the Symfony2 FrameworkHands-on with the Symfony2 Framework
Hands-on with the Symfony2 FrameworkRyan Weaver
 
A la découverte de TypeScript
A la découverte de TypeScriptA la découverte de TypeScript
A la découverte de TypeScriptDenis Voituron
 
Fluent Development with FLOW3
Fluent Development with FLOW3Fluent Development with FLOW3
Fluent Development with FLOW3Robert Lemke
 
Laravel Beginners Tutorial 1
Laravel Beginners Tutorial 1Laravel Beginners Tutorial 1
Laravel Beginners Tutorial 1Vikas Chauhan
 

What's hot (20)

クリーンアーキテクチャの考え方にもとづく Laravel との付き合い方 #phpcondo
クリーンアーキテクチャの考え方にもとづく Laravel との付き合い方 #phpcondoクリーンアーキテクチャの考え方にもとづく Laravel との付き合い方 #phpcondo
クリーンアーキテクチャの考え方にもとづく Laravel との付き合い方 #phpcondo
 
Kyiv.py #17 Flask talk
Kyiv.py #17 Flask talkKyiv.py #17 Flask talk
Kyiv.py #17 Flask talk
 
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterSymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
 
LvivPy - Flask in details
LvivPy - Flask in detailsLvivPy - Flask in details
LvivPy - Flask in details
 
appledoc_style
appledoc_styleappledoc_style
appledoc_style
 
Python/Flask Presentation
Python/Flask PresentationPython/Flask Presentation
Python/Flask Presentation
 
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
 
Build restful ap is with python and flask
Build restful ap is with python and flaskBuild restful ap is with python and flask
Build restful ap is with python and flask
 
Web develop in flask
Web develop in flaskWeb develop in flask
Web develop in flask
 
Cis407 a ilab 4 web application development devry university
Cis407 a ilab 4 web application development devry universityCis407 a ilab 4 web application development devry university
Cis407 a ilab 4 web application development devry university
 
Willow, the interaction tour
Willow, the interaction tourWillow, the interaction tour
Willow, the interaction tour
 
Quick flask an intro to flask
Quick flask   an intro to flaskQuick flask   an intro to flask
Quick flask an intro to flask
 
Flask patterns
Flask patternsFlask patterns
Flask patterns
 
Flask Basics
Flask BasicsFlask Basics
Flask Basics
 
What The Flask? and how to use it with some Google APIs
What The Flask? and how to use it with some Google APIsWhat The Flask? and how to use it with some Google APIs
What The Flask? and how to use it with some Google APIs
 
Flask – Python
Flask – PythonFlask – Python
Flask – Python
 
Hands-on with the Symfony2 Framework
Hands-on with the Symfony2 FrameworkHands-on with the Symfony2 Framework
Hands-on with the Symfony2 Framework
 
A la découverte de TypeScript
A la découverte de TypeScriptA la découverte de TypeScript
A la découverte de TypeScript
 
Fluent Development with FLOW3
Fluent Development with FLOW3Fluent Development with FLOW3
Fluent Development with FLOW3
 
Laravel Beginners Tutorial 1
Laravel Beginners Tutorial 1Laravel Beginners Tutorial 1
Laravel Beginners Tutorial 1
 

Similar to Create Clean Code with AOP at WebExpo 2010

Creating Clean Code with AOP
Creating Clean Code with AOPCreating Clean Code with AOP
Creating Clean Code with AOPRobert Lemke
 
Creating Clean Code with AOP
Creating Clean Code with AOPCreating Clean Code with AOP
Creating Clean Code with AOPRobert Lemke
 
Building websites with TYPO3 Neos
Building websites with TYPO3 NeosBuilding websites with TYPO3 Neos
Building websites with TYPO3 NeosFedir RYKHTIK
 
Where's the source, Luke? : How to find and debug the code behind Plone
Where's the source, Luke? : How to find and debug the code behind PloneWhere's the source, Luke? : How to find and debug the code behind Plone
Where's the source, Luke? : How to find and debug the code behind PloneVincenzo Barone
 
Rifartek Robot Training Course - How to use ClientRobot
Rifartek Robot Training Course - How to use ClientRobotRifartek Robot Training Course - How to use ClientRobot
Rifartek Robot Training Course - How to use ClientRobotTsai Tsung-Yi
 
Simplify your professional web development with symfony
Simplify your professional web development with symfonySimplify your professional web development with symfony
Simplify your professional web development with symfonyFrancois Zaninotto
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy CodeRowan Merewood
 
MongoDB - How to model and extract your data
MongoDB - How to model and extract your dataMongoDB - How to model and extract your data
MongoDB - How to model and extract your dataFrancesco Lo Franco
 
Introduction to Google App Engine with Python
Introduction to Google App Engine with PythonIntroduction to Google App Engine with Python
Introduction to Google App Engine with PythonBrian Lyttle
 
Creating Clean Code with AOP (T3CON10)
Creating Clean Code with AOP (T3CON10)Creating Clean Code with AOP (T3CON10)
Creating Clean Code with AOP (T3CON10)Robert Lemke
 
JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...
JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...
JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...Guillaume Laforge
 
Introduction of Pharo 5.0
Introduction of Pharo 5.0Introduction of Pharo 5.0
Introduction of Pharo 5.0Masashi Umezawa
 
Building Large Scale PHP Web Applications with Laravel 4
Building Large Scale PHP Web Applications with Laravel 4Building Large Scale PHP Web Applications with Laravel 4
Building Large Scale PHP Web Applications with Laravel 4Darwin Biler
 
Folio3 - An Introduction to PHP Yii
Folio3 - An Introduction to PHP YiiFolio3 - An Introduction to PHP Yii
Folio3 - An Introduction to PHP YiiFolio3 Software
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkBo-Yi Wu
 
Googleappengineintro 110410190620-phpapp01
Googleappengineintro 110410190620-phpapp01Googleappengineintro 110410190620-phpapp01
Googleappengineintro 110410190620-phpapp01Tony Frame
 
"I have a framework idea" - Repeat less, share more.
"I have a framework idea" - Repeat less, share more."I have a framework idea" - Repeat less, share more.
"I have a framework idea" - Repeat less, share more.Fabio Milano
 

Similar to Create Clean Code with AOP at WebExpo 2010 (20)

Creating Clean Code with AOP
Creating Clean Code with AOPCreating Clean Code with AOP
Creating Clean Code with AOP
 
Creating Clean Code with AOP
Creating Clean Code with AOPCreating Clean Code with AOP
Creating Clean Code with AOP
 
WebGUI Developers Workshop
WebGUI Developers WorkshopWebGUI Developers Workshop
WebGUI Developers Workshop
 
Django introduction
Django introductionDjango introduction
Django introduction
 
Building websites with TYPO3 Neos
Building websites with TYPO3 NeosBuilding websites with TYPO3 Neos
Building websites with TYPO3 Neos
 
Where's the source, Luke? : How to find and debug the code behind Plone
Where's the source, Luke? : How to find and debug the code behind PloneWhere's the source, Luke? : How to find and debug the code behind Plone
Where's the source, Luke? : How to find and debug the code behind Plone
 
Rifartek Robot Training Course - How to use ClientRobot
Rifartek Robot Training Course - How to use ClientRobotRifartek Robot Training Course - How to use ClientRobot
Rifartek Robot Training Course - How to use ClientRobot
 
Simplify your professional web development with symfony
Simplify your professional web development with symfonySimplify your professional web development with symfony
Simplify your professional web development with symfony
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy Code
 
MVC for TYPO3 4.3 with extbase
MVC for TYPO3 4.3 with extbaseMVC for TYPO3 4.3 with extbase
MVC for TYPO3 4.3 with extbase
 
MongoDB - How to model and extract your data
MongoDB - How to model and extract your dataMongoDB - How to model and extract your data
MongoDB - How to model and extract your data
 
Introduction to Google App Engine with Python
Introduction to Google App Engine with PythonIntroduction to Google App Engine with Python
Introduction to Google App Engine with Python
 
Creating Clean Code with AOP (T3CON10)
Creating Clean Code with AOP (T3CON10)Creating Clean Code with AOP (T3CON10)
Creating Clean Code with AOP (T3CON10)
 
JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...
JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...
JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...
 
Introduction of Pharo 5.0
Introduction of Pharo 5.0Introduction of Pharo 5.0
Introduction of Pharo 5.0
 
Building Large Scale PHP Web Applications with Laravel 4
Building Large Scale PHP Web Applications with Laravel 4Building Large Scale PHP Web Applications with Laravel 4
Building Large Scale PHP Web Applications with Laravel 4
 
Folio3 - An Introduction to PHP Yii
Folio3 - An Introduction to PHP YiiFolio3 - An Introduction to PHP Yii
Folio3 - An Introduction to PHP Yii
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC Framework
 
Googleappengineintro 110410190620-phpapp01
Googleappengineintro 110410190620-phpapp01Googleappengineintro 110410190620-phpapp01
Googleappengineintro 110410190620-phpapp01
 
"I have a framework idea" - Repeat less, share more.
"I have a framework idea" - Repeat less, share more."I have a framework idea" - Repeat less, share more.
"I have a framework idea" - Repeat less, share more.
 

More from Robert Lemke

Neos Content Repository – Git for content
Neos Content Repository – Git for contentNeos Content Repository – Git for content
Neos Content Repository – Git for contentRobert Lemke
 
A General Purpose Docker Image for PHP
A General Purpose Docker Image for PHPA General Purpose Docker Image for PHP
A General Purpose Docker Image for PHPRobert Lemke
 
Scaleable PHP Applications in Kubernetes
Scaleable PHP Applications in KubernetesScaleable PHP Applications in Kubernetes
Scaleable PHP Applications in KubernetesRobert Lemke
 
Flownative Beach - Neos Meetup Hamburg 2022
Flownative Beach - Neos Meetup Hamburg 2022Flownative Beach - Neos Meetup Hamburg 2022
Flownative Beach - Neos Meetup Hamburg 2022Robert Lemke
 
GitOps with Flux - IPC Munich 2022
GitOps with Flux - IPC Munich 2022GitOps with Flux - IPC Munich 2022
GitOps with Flux - IPC Munich 2022Robert Lemke
 
OpenID Connect with Neos and Flow
OpenID Connect with Neos and FlowOpenID Connect with Neos and Flow
OpenID Connect with Neos and FlowRobert Lemke
 
Neos Conference 2019 Keynote
Neos Conference 2019 KeynoteNeos Conference 2019 Keynote
Neos Conference 2019 KeynoteRobert Lemke
 
A practical introduction to Kubernetes (IPC 2018)
A practical introduction to Kubernetes (IPC 2018)A practical introduction to Kubernetes (IPC 2018)
A practical introduction to Kubernetes (IPC 2018)Robert Lemke
 
Neos Conference 2018 Welcome Keynote
Neos Conference 2018 Welcome KeynoteNeos Conference 2018 Welcome Keynote
Neos Conference 2018 Welcome KeynoteRobert Lemke
 
A practical introduction to Event Sourcing and CQRS
A practical introduction to Event Sourcing and CQRSA practical introduction to Event Sourcing and CQRS
A practical introduction to Event Sourcing and CQRSRobert Lemke
 
Neos Conference 2017 Welcome Keynote
Neos Conference 2017 Welcome KeynoteNeos Conference 2017 Welcome Keynote
Neos Conference 2017 Welcome KeynoteRobert Lemke
 
IPC16: A Practical Introduction to Kubernetes
IPC16: A Practical Introduction to Kubernetes IPC16: A Practical Introduction to Kubernetes
IPC16: A Practical Introduction to Kubernetes Robert Lemke
 
IPC 2016: Content Strategy for Developers
IPC 2016: Content Strategy for DevelopersIPC 2016: Content Strategy for Developers
IPC 2016: Content Strategy for DevelopersRobert Lemke
 
Docker in Production - IPC 2016
Docker in Production - IPC 2016Docker in Production - IPC 2016
Docker in Production - IPC 2016Robert Lemke
 
Is this Open Source Thing Really Worth it? (IPC 2016 Berlin)
Is this Open Source Thing Really Worth it? (IPC 2016 Berlin)Is this Open Source Thing Really Worth it? (IPC 2016 Berlin)
Is this Open Source Thing Really Worth it? (IPC 2016 Berlin)Robert Lemke
 
The Neos Brand (Inspiring Conference 2016)
The Neos Brand (Inspiring Conference 2016)The Neos Brand (Inspiring Conference 2016)
The Neos Brand (Inspiring Conference 2016)Robert Lemke
 
Neos - past, present, future (Inspiring Conference 2016)
Neos - past, present, future (Inspiring Conference 2016)Neos - past, present, future (Inspiring Conference 2016)
Neos - past, present, future (Inspiring Conference 2016)Robert Lemke
 
Meet Neos Nürnberg 2016: Ja ich will!
Meet Neos Nürnberg 2016: Ja ich will!Meet Neos Nürnberg 2016: Ja ich will!
Meet Neos Nürnberg 2016: Ja ich will!Robert Lemke
 
Meet Neos Nürnberg 2016: Hallo Neos!
Meet Neos Nürnberg 2016: Hallo Neos!Meet Neos Nürnberg 2016: Hallo Neos!
Meet Neos Nürnberg 2016: Hallo Neos!Robert Lemke
 
Turning Neos inside out / React.js HH
Turning Neos inside out / React.js HHTurning Neos inside out / React.js HH
Turning Neos inside out / React.js HHRobert Lemke
 

More from Robert Lemke (20)

Neos Content Repository – Git for content
Neos Content Repository – Git for contentNeos Content Repository – Git for content
Neos Content Repository – Git for content
 
A General Purpose Docker Image for PHP
A General Purpose Docker Image for PHPA General Purpose Docker Image for PHP
A General Purpose Docker Image for PHP
 
Scaleable PHP Applications in Kubernetes
Scaleable PHP Applications in KubernetesScaleable PHP Applications in Kubernetes
Scaleable PHP Applications in Kubernetes
 
Flownative Beach - Neos Meetup Hamburg 2022
Flownative Beach - Neos Meetup Hamburg 2022Flownative Beach - Neos Meetup Hamburg 2022
Flownative Beach - Neos Meetup Hamburg 2022
 
GitOps with Flux - IPC Munich 2022
GitOps with Flux - IPC Munich 2022GitOps with Flux - IPC Munich 2022
GitOps with Flux - IPC Munich 2022
 
OpenID Connect with Neos and Flow
OpenID Connect with Neos and FlowOpenID Connect with Neos and Flow
OpenID Connect with Neos and Flow
 
Neos Conference 2019 Keynote
Neos Conference 2019 KeynoteNeos Conference 2019 Keynote
Neos Conference 2019 Keynote
 
A practical introduction to Kubernetes (IPC 2018)
A practical introduction to Kubernetes (IPC 2018)A practical introduction to Kubernetes (IPC 2018)
A practical introduction to Kubernetes (IPC 2018)
 
Neos Conference 2018 Welcome Keynote
Neos Conference 2018 Welcome KeynoteNeos Conference 2018 Welcome Keynote
Neos Conference 2018 Welcome Keynote
 
A practical introduction to Event Sourcing and CQRS
A practical introduction to Event Sourcing and CQRSA practical introduction to Event Sourcing and CQRS
A practical introduction to Event Sourcing and CQRS
 
Neos Conference 2017 Welcome Keynote
Neos Conference 2017 Welcome KeynoteNeos Conference 2017 Welcome Keynote
Neos Conference 2017 Welcome Keynote
 
IPC16: A Practical Introduction to Kubernetes
IPC16: A Practical Introduction to Kubernetes IPC16: A Practical Introduction to Kubernetes
IPC16: A Practical Introduction to Kubernetes
 
IPC 2016: Content Strategy for Developers
IPC 2016: Content Strategy for DevelopersIPC 2016: Content Strategy for Developers
IPC 2016: Content Strategy for Developers
 
Docker in Production - IPC 2016
Docker in Production - IPC 2016Docker in Production - IPC 2016
Docker in Production - IPC 2016
 
Is this Open Source Thing Really Worth it? (IPC 2016 Berlin)
Is this Open Source Thing Really Worth it? (IPC 2016 Berlin)Is this Open Source Thing Really Worth it? (IPC 2016 Berlin)
Is this Open Source Thing Really Worth it? (IPC 2016 Berlin)
 
The Neos Brand (Inspiring Conference 2016)
The Neos Brand (Inspiring Conference 2016)The Neos Brand (Inspiring Conference 2016)
The Neos Brand (Inspiring Conference 2016)
 
Neos - past, present, future (Inspiring Conference 2016)
Neos - past, present, future (Inspiring Conference 2016)Neos - past, present, future (Inspiring Conference 2016)
Neos - past, present, future (Inspiring Conference 2016)
 
Meet Neos Nürnberg 2016: Ja ich will!
Meet Neos Nürnberg 2016: Ja ich will!Meet Neos Nürnberg 2016: Ja ich will!
Meet Neos Nürnberg 2016: Ja ich will!
 
Meet Neos Nürnberg 2016: Hallo Neos!
Meet Neos Nürnberg 2016: Hallo Neos!Meet Neos Nürnberg 2016: Hallo Neos!
Meet Neos Nürnberg 2016: Hallo Neos!
 
Turning Neos inside out / React.js HH
Turning Neos inside out / React.js HHTurning Neos inside out / React.js HH
Turning Neos inside out / React.js HH
 

Create Clean Code with AOP at WebExpo 2010

  • 1. Robert Lemke Create Clean Code with Aspect-Oriented Programming WebExpo 2010, Prague Photo: Robert Szlivka
  • 2. Robert Lemke chief architect of TYPO3 Phoenix and FLOW3 co-founder of the TYPO3 Association 34 years old lives in Lübeck, Germany 1 wife, 1 daughter, 1 espresso machine likes drumming
  • 5. www.typo3.org Create Clean Code with AOP WebExpo 2010, Prague
  • 6.
  • 7.
  • 8.
  • 9. = PHP 5.3 Full Stack Application Framework
  • 10. DI Dependency Injection DRY YAA OOP Object-Oriented Programming YAGNI AOP Aspect-Oriented Programming CoC MVC Model View Controller POPO Plain Old PHP Object TDD
  • 11. /** * Creates a new post * * @param F3BlogDomainModelPost $newPost A fresh Post object which has not yet been * added to the repository * @return void */ public function createAction(F3BlogDomainModelPost $newPost) { if ($this->policyService->isGranted($this->currentUser, __CLASS__, __METHOD__) { $this->blog->addPost($newPost); $this->flashMessageContainer->add('Your new post was created.'); $this->systemLogger->log('A new post was created.', LOG_INFO); $this->notificationService->notify('A new post was created.', 'robert@typo3.org'); } else { $this->systemLogger->log('Someone tried to create a post.', LOG_WARNING); throw new F3FLOW3SecurityExceptionAccessDeniedException('Tried to create.'); } $this->redirect('index'); } Create Clean Code with AOP WebExpo 2010, Prague
  • 12. /** * Creates a new post * * @param F3BlogDomainModelPost $newPost A fresh Post object which has not yet been * added to the repository * @return void */ public function createAction(F3BlogDomainModelPost $newPost) { if ($this->policyService->isGranted($this->currentUser, __CLASS__, __METHOD__) { $this->blog->addPost($newPost); $this->flashMessageContainer->add('Your new post was created.'); $this->systemLogger->log('A new post was created.', LOG_INFO); $this->notificationService->notify('A new post was created.', 'robert@typo3.org'); } else { $this->systemLogger->log('Someone tried to create a post.', LOG_WARNING); throw new F3FLOW3SecurityExceptionAccessDeniedException('Tried to create.'); } $this->redirect('index'); } Create Clean Code with AOP WebExpo 2010, Prague
  • 13. Create Clean Code with AOP WebExpo 2010, Prague
  • 14. AOP Create Clean Code with AOP WebExpo 2010, Prague
  • 15. Aspect-Oriented Programming programming paradigm separates concerns to improve modularization OOP modularizes concerns into objects AOP modularizes cross-cutting concerns into aspects Create Clean Code with AOP WebExpo 2010, Prague
  • 16. /** * Creates a new post * * @param F3BlogDomainModelPost $newPost A fresh Post object which has not yet been * added to the repository * @return void */ public function createAction(F3BlogDomainModelPost $newPost) { $this->blog->addPost($newPost); $this->flashMessageContainer->add('Your new post was created.'); $this->redirect('index'); } Create Clean Code with AOP WebExpo 2010, Prague
  • 17. Concerns? Create Clean Code with AOP WebExpo 2010, Prague
  • 18. Concerns Separation of Concerns group features and behavior into manageable parts have a specific purpose and business to take care of Cross-Cutting Concerns are the party poopers who want to have a say in everything Create Clean Code with AOP WebExpo 2010, Prague
  • 19. Cross-Cutting Concerns Logging Security Persistence Global Business Logic Dirty Hacks Create Clean Code with AOP WebExpo 2010, Prague
  • 20. We don't want infrastructure code in our models. Create Clean Code with AOP WebExpo 2010, Prague
  • 21. We want to unit-test even cross-cutting concerns Create Clean Code with AOP WebExpo 2010, Prague
  • 22. We want to centralize security-related code Create Clean Code with AOP WebExpo 2010, Prague
  • 23. AOP Lingo Create Clean Code with AOP WebExpo 2010, Prague
  • 24. Aspect Part of the application where cross-cutting concerns are implemented In FLOW3 aspects are classes annotated with @aspect Create Clean Code with AOP WebExpo 2010, Prague
  • 25. Join Point Is a single point in the call graph Method Execution Exception Represents an event, not a location Create Clean Code with AOP WebExpo 2010, Prague
  • 26. Pointcut A set of join points where advices could be executed can be composed can be named Create Clean Code with AOP WebExpo 2010, Prague
  • 27. Advice Action to take at a join points defined by the point cut Create Clean Code with AOP WebExpo 2010, Prague
  • 28. DEMO Inspiring people to Hitchhiker's Guide to FLOW3 share
  • 29. Kinds of Advice Advice types supported by FLOW3: @before @afterreturning @afterthrowing @after @around Inspiring people to Hitchhiker's Guide to FLOW3 share
  • 31. Runtime Evaluations evaluate(coffee.kind == "Arabica") Inspiring people to Hitchhiker's Guide to FLOW3 share
  • 32. Compound Pointcuts ! /** !  * @around method(.*Controller->(new|create|edit|update|delete)Action()) &&  !methodTaggedWith(anybodyMayAccessThis) !  */ ! public function interceptMethodCalls($joinPoint) { ... } Inspiring people to Hitchhiker's Guide to FLOW3 share
  • 33. DEMO Inspiring people to Hitchhiker's Guide to FLOW3 share
  • 34. FLOW3's AOP implementation based on proxy classes unlike with most pre-processors line numbers stay the same no scaffolding 0 Lines of generated code which need to be maintained by you fast (on the second hit) Inspiring people to Hitchhiker's Guide to FLOW3 share
  • 35. Inspiring people to Hitchhiker's Guide to FLOW3 share
  • 36. Inspiring people to Hitchhiker's Guide to FLOW3 share
  • 37. Progress FLOW3 1.0.0 Create Clean Code with AOP WebExpo 2010, Prague
  • 38. Further Reading FLOW3 Website http://flow3.typo3.org FLOW3 Download http://flow3.typo3.org/download git://git.typo3.org/FLOW3/Distributions/Base.git TYPO3 Forge http://forge.typo3.org Further Reading http://flow3.typo3.org/about/principles/further-reading Create Clean Code with AOP WebExpo 2010, Prague
  • 39. Questions Email: robert@typo3.org Blog: http://robertlemke.de/blog Twitter: @t3rob Slides: http://slideshare.net/rlmp Create Clean Code with AOP WebExpo 2010, Prague