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 full-size 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 full-size 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 full-size slide

  4. Mediator Pattern
    @phpconfasia
    ATC Tower

    View full-size slide

  5. Architecture
    @phpconfasia
    Client

    View full-size slide

  6. Architecture
    @phpconfasia
    Client Event

    View full-size slide

  7. Architecture
    @phpconfasia
    Client Event Mediator

    View full-size slide

  8. Architecture
    @phpconfasia
    Client Event Mediator
    Listener
    Listener
    Listener

    View full-size slide

  9. Mediator Interface
    @phpconfasia

    View full-size 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 full-size slide

  11. Example
    @phpconfasia

    View full-size slide

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

    View full-size slide

  13. I can’t handle this
    @phpconfasia

    View full-size slide

  14. Notify Only ‘Hooks’
    @phpconfasia

    Don't change behavior

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

    View full-size slide

  15. Example
    @phpconfasia

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide