Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Event Driven Application

Event Driven Application

Presented by Prasetyo Wicaksono (@praswicaksono)

In this talk I want to present Event Driven Application by using mediator pattern. It would help decouple your code but beware there are some cons by using this pattern such as hard to track if your apps grown bigger.

PHP Conference Asia

September 23, 2015
Tweet

More Decks by PHP Conference Asia

Other Decks in Programming

Transcript

  1. Event Driven Application
    @phpconfasia

    View Slide

  2. BIO
    @phpconfasia
    Prasetyo Wicaksono

    Head of IT Dept. at PT Zion
    Internasional Niaga

    @malangphp organizer

    Twitter : @praswicaksono

    Github: https://github.com/Atriedes

    View Slide

  3. Event
    @phpconfasia

    event is an action or occurrence recognized by
    software that may be handled by the software.
    Computer events can be generated or triggered by
    the system or by the user. Event can be defined as
    "a significant change in state“ – wikipedia

    View Slide

  4. Mediator Pattern
    @phpconfasia
    ATC Tower

    View Slide

  5. Architecture
    @phpconfasia
    Client

    View Slide

  6. Architecture
    @phpconfasia
    Client Event

    View Slide

  7. Architecture
    @phpconfasia
    Client Event Mediator

    View Slide

  8. Architecture
    @phpconfasia
    Client Event Mediator
    Listener
    Listener
    Listener

    View Slide

  9. Mediator Interface
    @phpconfasia

    View Slide

  10. Hook
    @phpconfasia

    In computer programming, the term hooking
    covers a range of techniques used to alter or
    augment the behavior of an operating system,
    of applications, or of other software
    components by intercepting function calls or
    messages or events passed between software
    components. Code that handles such
    intercepted function calls, events or messages
    is called a "hook". - wikipedia

    View Slide

  11. Example
    @phpconfasia

    View Slide

  12. Prioritize Listener
    @phpconfasia
    Client Event Mediator
    1 – Make
    sure title is
    upper case
    2 -
    Uppercase
    Title
    3 - Sanitize
    Body

    View Slide

  13. I can’t handle this
    @phpconfasia

    View Slide

  14. Notify Only ‘Hooks’
    @phpconfasia

    Don't change behavior

    Only notify activity such as logging, sending
    email, updating cache

    View Slide

  15. Example
    @phpconfasia

    View Slide

  16. Notify Only ‘Hook’ + Background
    Process
    =
    @phpconfasia

    View Slide

  17. @phpconfasia
    “Most of all, experiment.
    Make mistakes. Talk about
    them.” Igor Wiedler

    View Slide

  18. Thanks
    @phpconfasia
    https://joind.in/15385
    @praswicaksono

    View Slide