SlideShare una empresa de Scribd logo
1 de 44
Descargar para leer sin conexión
Beautiful Code with AOP and DI
International PHP Conference – Frankfurt, Germany
CAUTION!
HOT CODE
Overview
  Background Information
  Domain Driven Design
  Components and
  Dependecy Injection
  Aspect Oriented Programming
  TYPO3 Framework
Background Information


Mission "Ease of Use"
    "Ease of Use" has been identified as the main topic for next
    TYPO3 versions

    First steps were founding the TYPO3 Association, building a
    brand and "zapping the Gremlins"

    Decision to rewrite TYPO3 based on a new architecture to
    achieve Ease of Use for developers

    Currently TYPO3 5.0 is being developed - the 4.x branch will still
    be improved and see new features
Background Information


Core + Extensions = TYPO3
Background Information


Three Sub-Projects



       TYPO3 CMS         TYPO3 Fr amework   TYPO3 CR
Background Information


Empty Canvas




                         ?
Background Information


(Some) Guiding Principles
    anticipate real world needs

    focus on the domain

    centralize concerns

    convention over configuration

    human readable code

    modularity everywhere

    design decisions can be changed
Background Information

5 Development Methods
                    Domain
                 Driven Design
                                               Don't
      Work where it matters (DDD)          Repeat Yourself
                                Test Driven
      Work where it belongs to (DRY)
                                Development
      No chaos, ever (TDD)       Continuous
                                                  Dependency Injection
                                 Integration
                                               Aspect Orient Programming
      No bad surprises (CI)                     Graphical User Interface

      Innovation built-in (DI, AOP, GUI)

      ... and more XP techniques
Domain Driven Design
  A domain is the activity or business of the user

  Domain Driven Design is about

    focussing on the domain and domain logic

    accurately mapping the domain concepts to software

    forming a ubiquitous language among the project members
Domain Driven Design
Why focus on the Domain?

Most time in development is spent on
infrastructure instead of user interfaces and
business logic.

We don't want that.
Domain Driven Design


Ubiquitous language
    The common vocabulary is an important prerequisite
    for successful collaboration

    Use the same words for discussion, modeling, development
    and documentation
Domain Driven Design


Phone Book Domain Model
Domain Driven Design


More phone book actions
    show phone book entries

    check if user may delete phone book entry

    export phone book entries

    log phone book actions
✘
Domain Driven Design


More phone book actions
    show phone book entries      not in
                              domain
    check if user may delete phone book entry
                                               the
    export phone book entries                 of a
                              phone
    log phone book actions                  book
Domain Driven Design


Layered Architecture

                   View
 Presentation
                   Controller
                   Application Logic (Service Layer)
    Domain
                   Domain Model (Domain Layer)
                   Data Mapper (part of Content Repository)
 Data source
                   Data Source Abstraction
Domain Driven Design


Layered Architecture

                   View
 Presentation
                   Controller
                   Application Logic (Service Layer)
    Domain
                   Domain Model (Domain Layer)
                   Data Mapper (part of Content Repository)
 Data source
                   Data Source Abstraction
Domain Driven Design


Domain-Driven Design
       „Cancel the registration for Mr. Sarkosh“

  $res = $DB->execQuery('SELECT cnumber FROM customers WHERE lastname LIKE "Sarkosh"');
  if (!$res) throw new Exception;
  $c = mysql_fetch_assoc($res);
  if (!is_array($c)) throw new Exception;
  $res = $DB->execQuery('SELECT * FROM registrations WHERE cnumber =' . intval($c['cnumber']));
  $reg = mysql_fetch_assoc($res);
  if (!is_array($reg)) {
	     $this->log('Registration not found');
	     throw new Exception;
  }
  if (!$reg['status'] == 3) throw new Exception;
Domain Driven Design


Domain-Driven Design
    „Cancel the registration for Mr. Sarkosh“

    $customer = $this->customerRepository->findByLastname('Sarkosh');	
    $event = $this->eventRepository->getEvent('IPC07');
    $event->addParticipant($customer);
    $event->removeParticipant($customer);




    $customer = $this->customerRepository->findByLastname('Sarkosh');
    $event = $this->eventRepository->getEvent('IPC07');
    $registrationService->cancelRegistration($event, $customer);
Components
Components


Playing with building blocks
    In TYPO3 5.0, objects considered as components

    The combination of components used is configurable
    (orchestration)

    The less components know about each other the easier it is to
    reuse them in a variety of contexts

    Create your own LEGO set by creating cleanly separated,
    decoupled components!
Components


Component Dependencies
    Components seldomly come alone

    Components depend on other components which depend on
    other components which ...




                                        Inspiring people to
                                        share
Components


Component Dependencies
    Components seldomly come alone

    Components depend on other components which depend on
    other components which ...

    Problem:

      Components explicitly refer to other components:
      $event = new Event();




                                           Inspiring people to
                                           share
Components


Component Dependencies
    Possible solutions:

      Factory pattern (GoF):
      $event = EventFactory::createEvent();

      Registry pattern (Fowler) / Service Locator:
      class ServiceLocator {
         public function registerComponent($name, $component) {}
         public function getInstance($name);
      }



                                              Inspiring people to
                                              share
Components


Dependency Injection
    A component doesn't ask for the instance of another component
    but gets it injected

    This a type of "Inversion of Control" also referred to as the
    "Hollywood Principle": "Don't call us, we'll call you"

    Enforces loose coupling and high cohesion

    Makes you a better programmer
Components


Practical examples for DI
    Example using ...

      Constructor Injection

      Setter Injection

      Autowiring
                              Demo
Aspect Oriented Programming
  AOP is a programming paradigm

  complements OOP by separating concerns to improve
  modularization

  OOP modularizes concerns: methods, classes, packages

  AOP addresses cross-cutting concerns
Aspect Oriented Programming


Cross-cutting concerns

                       Presentation

                          Domain

                        Data source
Aspect Oriented Programming


Cross-cutting concerns

                       Presentation   The concerns
                                        live here

                          Domain

                        Data source
Aspect Oriented Programming


Cross-cutting concerns


                      Event Domain Model


                              Security     CONCERNS
                              Logging        X-ING
Aspect Oriented Programming


Some Definitions
    Advice
      encapsulated code, to be re-used
    Joinpoint
      places in the code where advice can be applied
    Pointcut
      identifies set of joinpoints where advice should be applied
    Aspect
      groups advices and pointcuts
Aspect Oriented Programming


Aspects in action



                        Demo
Read before first use


Try it yourself
Try it yourself


(Advertising)
     The TYPO3 Framework is the only PHP-based solution which
     truly supports Domain Driven Design

     powerful, transparent and plain PHP-based AOP support
     (no extension required, no compile step)

     full-featured IoC container with Dependency Injection

     great (and big) community, backed by the TYPO3 Association

     ....
Try it yourself


Installation
     You need PHP6

     Current installation options:

        svn checkout http://5-0.dev.typo3.org/svn/TYPO3/

        download the TYPO3 installer
Try it yourself


Installation
When ...?
Recommended literature
Recommended literature
             Eric Evans:
             Domain Driven Design
             Tackling Complexity in the Heart of
             Software


             Addison Wesley 2002
Recommended literature

             Martin Fowler:
             Patterns of Enterprise
             Application Architecture

             Addison Wesley 2002
Recommended literature

             Jimmy Nilsson:
             Applying Domain-Driven
             Design and Patterns
             Addison Wesley 2006
Links
  TYPO3 5.0 Subsite
  http://typo3.org/gimmefive

  TYPO3 5.0 Development Website
  http://5-0.dev.typo3.org

  TYPO3 5.0 Documentation
  http://5-0.dev.typo3.org/guide
So long and thanks for the fish


Questions
robert@typo3.org
IPC07 Talk - Beautiful Code with AOP and DI

Más contenido relacionado

Similar a IPC07 Talk - Beautiful Code with AOP and DI

Development with TYPO3 5.0
Development with TYPO3 5.0Development with TYPO3 5.0
Development with TYPO3 5.0Robert Lemke
 
X-celerate 2019: Iterating fast with the MERN Stack
X-celerate 2019: Iterating fast with the MERN StackX-celerate 2019: Iterating fast with the MERN Stack
X-celerate 2019: Iterating fast with the MERN StackHaufe-Lexware GmbH & Co KG
 
WSO2Con US 2013 - Keynote: Developing Enterprise Apps In the Cloud
WSO2Con US 2013 - Keynote: Developing Enterprise Apps In the CloudWSO2Con US 2013 - Keynote: Developing Enterprise Apps In the Cloud
WSO2Con US 2013 - Keynote: Developing Enterprise Apps In the CloudWSO2
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven DesignRyan Riley
 
Aspect Oriented Software Development
Aspect Oriented Software DevelopmentAspect Oriented Software Development
Aspect Oriented Software DevelopmentJignesh Patel
 
Latest trends in information technology
Latest trends in information technologyLatest trends in information technology
Latest trends in information technologyEldos Kuriakose
 
An insight to microsoft platform
An insight to microsoft platformAn insight to microsoft platform
An insight to microsoft platformConfiz
 
.NET Architecture for Enterprises
.NET Architecture for Enterprises.NET Architecture for Enterprises
.NET Architecture for EnterprisesWade Wegner
 
2011 iska - tim m - domain driven design
2011   iska - tim m - domain driven design2011   iska - tim m - domain driven design
2011 iska - tim m - domain driven designTim Mahy
 
Up to speed in domain driven design
Up to speed in domain driven designUp to speed in domain driven design
Up to speed in domain driven designRick van der Arend
 
Simon Brown: Software Architecture as Code at I T.A.K.E. Unconference 2015
Simon Brown: Software Architecture as Code at I T.A.K.E. Unconference 2015Simon Brown: Software Architecture as Code at I T.A.K.E. Unconference 2015
Simon Brown: Software Architecture as Code at I T.A.K.E. Unconference 2015Mozaic Works
 
Class 6: Introduction to web technology entrepreneurship
Class 6: Introduction to web technology entrepreneurshipClass 6: Introduction to web technology entrepreneurship
Class 6: Introduction to web technology entrepreneurshipallanchao
 
Introduction to Aspect Oriented Software Development
Introduction to Aspect Oriented Software DevelopmentIntroduction to Aspect Oriented Software Development
Introduction to Aspect Oriented Software Developmentmukhtarhudaya
 
So You Just Inherited a $Legacy Application… NomadPHP July 2016
So You Just Inherited a $Legacy Application… NomadPHP July 2016So You Just Inherited a $Legacy Application… NomadPHP July 2016
So You Just Inherited a $Legacy Application… NomadPHP July 2016Joe Ferguson
 
ZZ BC#7.5 asp.net mvc practice and guideline refresh!
ZZ BC#7.5 asp.net mvc practice  and guideline refresh! ZZ BC#7.5 asp.net mvc practice  and guideline refresh!
ZZ BC#7.5 asp.net mvc practice and guideline refresh! Chalermpon Areepong
 
So You Just Inherited a $Legacy Application...
So You Just Inherited a $Legacy Application...So You Just Inherited a $Legacy Application...
So You Just Inherited a $Legacy Application...Joe Ferguson
 

Similar a IPC07 Talk - Beautiful Code with AOP and DI (20)

RavenDB overview
RavenDB overviewRavenDB overview
RavenDB overview
 
Development with TYPO3 5.0
Development with TYPO3 5.0Development with TYPO3 5.0
Development with TYPO3 5.0
 
X-celerate 2019: Iterating fast with the MERN Stack
X-celerate 2019: Iterating fast with the MERN StackX-celerate 2019: Iterating fast with the MERN Stack
X-celerate 2019: Iterating fast with the MERN Stack
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
WSO2Con US 2013 - Keynote: Developing Enterprise Apps In the Cloud
WSO2Con US 2013 - Keynote: Developing Enterprise Apps In the CloudWSO2Con US 2013 - Keynote: Developing Enterprise Apps In the Cloud
WSO2Con US 2013 - Keynote: Developing Enterprise Apps In the Cloud
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Aspect Oriented Software Development
Aspect Oriented Software DevelopmentAspect Oriented Software Development
Aspect Oriented Software Development
 
Latest trends in information technology
Latest trends in information technologyLatest trends in information technology
Latest trends in information technology
 
An insight to microsoft platform
An insight to microsoft platformAn insight to microsoft platform
An insight to microsoft platform
 
.NET Architecture for Enterprises
.NET Architecture for Enterprises.NET Architecture for Enterprises
.NET Architecture for Enterprises
 
Django in the Real World
Django in the Real WorldDjango in the Real World
Django in the Real World
 
2011 iska - tim m - domain driven design
2011   iska - tim m - domain driven design2011   iska - tim m - domain driven design
2011 iska - tim m - domain driven design
 
Up to speed in domain driven design
Up to speed in domain driven designUp to speed in domain driven design
Up to speed in domain driven design
 
Simon Brown: Software Architecture as Code at I T.A.K.E. Unconference 2015
Simon Brown: Software Architecture as Code at I T.A.K.E. Unconference 2015Simon Brown: Software Architecture as Code at I T.A.K.E. Unconference 2015
Simon Brown: Software Architecture as Code at I T.A.K.E. Unconference 2015
 
Class 6: Introduction to web technology entrepreneurship
Class 6: Introduction to web technology entrepreneurshipClass 6: Introduction to web technology entrepreneurship
Class 6: Introduction to web technology entrepreneurship
 
Introduction to Aspect Oriented Software Development
Introduction to Aspect Oriented Software DevelopmentIntroduction to Aspect Oriented Software Development
Introduction to Aspect Oriented Software Development
 
So You Just Inherited a $Legacy Application… NomadPHP July 2016
So You Just Inherited a $Legacy Application… NomadPHP July 2016So You Just Inherited a $Legacy Application… NomadPHP July 2016
So You Just Inherited a $Legacy Application… NomadPHP July 2016
 
ZZ BC#7.5 asp.net mvc practice and guideline refresh!
ZZ BC#7.5 asp.net mvc practice  and guideline refresh! ZZ BC#7.5 asp.net mvc practice  and guideline refresh!
ZZ BC#7.5 asp.net mvc practice and guideline refresh!
 
Android Deep Dive
Android Deep DiveAndroid Deep Dive
Android Deep Dive
 
So You Just Inherited a $Legacy Application...
So You Just Inherited a $Legacy Application...So You Just Inherited a $Legacy Application...
So You Just Inherited a $Legacy Application...
 

Más de 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
 

Más de 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
 

IPC07 Talk - Beautiful Code with AOP and DI

  • 1. Beautiful Code with AOP and DI International PHP Conference – Frankfurt, Germany
  • 3. Overview Background Information Domain Driven Design Components and Dependecy Injection Aspect Oriented Programming TYPO3 Framework
  • 4. Background Information Mission "Ease of Use" "Ease of Use" has been identified as the main topic for next TYPO3 versions First steps were founding the TYPO3 Association, building a brand and "zapping the Gremlins" Decision to rewrite TYPO3 based on a new architecture to achieve Ease of Use for developers Currently TYPO3 5.0 is being developed - the 4.x branch will still be improved and see new features
  • 5. Background Information Core + Extensions = TYPO3
  • 6. Background Information Three Sub-Projects TYPO3 CMS TYPO3 Fr amework TYPO3 CR
  • 8. Background Information (Some) Guiding Principles anticipate real world needs focus on the domain centralize concerns convention over configuration human readable code modularity everywhere design decisions can be changed
  • 9. Background Information 5 Development Methods Domain Driven Design Don't Work where it matters (DDD) Repeat Yourself Test Driven Work where it belongs to (DRY) Development No chaos, ever (TDD) Continuous Dependency Injection Integration Aspect Orient Programming No bad surprises (CI) Graphical User Interface Innovation built-in (DI, AOP, GUI) ... and more XP techniques
  • 10. Domain Driven Design A domain is the activity or business of the user Domain Driven Design is about focussing on the domain and domain logic accurately mapping the domain concepts to software forming a ubiquitous language among the project members
  • 11. Domain Driven Design Why focus on the Domain? Most time in development is spent on infrastructure instead of user interfaces and business logic. We don't want that.
  • 12. Domain Driven Design Ubiquitous language The common vocabulary is an important prerequisite for successful collaboration Use the same words for discussion, modeling, development and documentation
  • 13. Domain Driven Design Phone Book Domain Model
  • 14. Domain Driven Design More phone book actions show phone book entries check if user may delete phone book entry export phone book entries log phone book actions
  • 15. ✘ Domain Driven Design More phone book actions show phone book entries not in domain check if user may delete phone book entry the export phone book entries of a phone log phone book actions book
  • 16. Domain Driven Design Layered Architecture View Presentation Controller Application Logic (Service Layer) Domain Domain Model (Domain Layer) Data Mapper (part of Content Repository) Data source Data Source Abstraction
  • 17. Domain Driven Design Layered Architecture View Presentation Controller Application Logic (Service Layer) Domain Domain Model (Domain Layer) Data Mapper (part of Content Repository) Data source Data Source Abstraction
  • 18. Domain Driven Design Domain-Driven Design „Cancel the registration for Mr. Sarkosh“ $res = $DB->execQuery('SELECT cnumber FROM customers WHERE lastname LIKE "Sarkosh"'); if (!$res) throw new Exception; $c = mysql_fetch_assoc($res); if (!is_array($c)) throw new Exception; $res = $DB->execQuery('SELECT * FROM registrations WHERE cnumber =' . intval($c['cnumber'])); $reg = mysql_fetch_assoc($res); if (!is_array($reg)) { $this->log('Registration not found'); throw new Exception; } if (!$reg['status'] == 3) throw new Exception;
  • 19. Domain Driven Design Domain-Driven Design „Cancel the registration for Mr. Sarkosh“ $customer = $this->customerRepository->findByLastname('Sarkosh'); $event = $this->eventRepository->getEvent('IPC07'); $event->addParticipant($customer); $event->removeParticipant($customer); $customer = $this->customerRepository->findByLastname('Sarkosh'); $event = $this->eventRepository->getEvent('IPC07'); $registrationService->cancelRegistration($event, $customer);
  • 21. Components Playing with building blocks In TYPO3 5.0, objects considered as components The combination of components used is configurable (orchestration) The less components know about each other the easier it is to reuse them in a variety of contexts Create your own LEGO set by creating cleanly separated, decoupled components!
  • 22. Components Component Dependencies Components seldomly come alone Components depend on other components which depend on other components which ... Inspiring people to share
  • 23. Components Component Dependencies Components seldomly come alone Components depend on other components which depend on other components which ... Problem: Components explicitly refer to other components: $event = new Event(); Inspiring people to share
  • 24. Components Component Dependencies Possible solutions: Factory pattern (GoF): $event = EventFactory::createEvent(); Registry pattern (Fowler) / Service Locator: class ServiceLocator { public function registerComponent($name, $component) {} public function getInstance($name); } Inspiring people to share
  • 25. Components Dependency Injection A component doesn't ask for the instance of another component but gets it injected This a type of "Inversion of Control" also referred to as the "Hollywood Principle": "Don't call us, we'll call you" Enforces loose coupling and high cohesion Makes you a better programmer
  • 26. Components Practical examples for DI Example using ... Constructor Injection Setter Injection Autowiring Demo
  • 27. Aspect Oriented Programming AOP is a programming paradigm complements OOP by separating concerns to improve modularization OOP modularizes concerns: methods, classes, packages AOP addresses cross-cutting concerns
  • 28. Aspect Oriented Programming Cross-cutting concerns Presentation Domain Data source
  • 29. Aspect Oriented Programming Cross-cutting concerns Presentation The concerns live here Domain Data source
  • 30. Aspect Oriented Programming Cross-cutting concerns Event Domain Model Security CONCERNS Logging X-ING
  • 31. Aspect Oriented Programming Some Definitions Advice encapsulated code, to be re-used Joinpoint places in the code where advice can be applied Pointcut identifies set of joinpoints where advice should be applied Aspect groups advices and pointcuts
  • 33. Read before first use Try it yourself
  • 34. Try it yourself (Advertising) The TYPO3 Framework is the only PHP-based solution which truly supports Domain Driven Design powerful, transparent and plain PHP-based AOP support (no extension required, no compile step) full-featured IoC container with Dependency Injection great (and big) community, backed by the TYPO3 Association ....
  • 35. Try it yourself Installation You need PHP6 Current installation options: svn checkout http://5-0.dev.typo3.org/svn/TYPO3/ download the TYPO3 installer
  • 39. Recommended literature Eric Evans: Domain Driven Design Tackling Complexity in the Heart of Software Addison Wesley 2002
  • 40. Recommended literature Martin Fowler: Patterns of Enterprise Application Architecture Addison Wesley 2002
  • 41. Recommended literature Jimmy Nilsson: Applying Domain-Driven Design and Patterns Addison Wesley 2006
  • 42. Links TYPO3 5.0 Subsite http://typo3.org/gimmefive TYPO3 5.0 Development Website http://5-0.dev.typo3.org TYPO3 5.0 Documentation http://5-0.dev.typo3.org/guide
  • 43. So long and thanks for the fish Questions robert@typo3.org