$30 off During Our Annual Pro Sale. View Details »

Declarative programming winning examples

Udi h Bauman
December 01, 2014

Declarative programming winning examples

Lightning talk for PyWeb #40

Udi h Bauman

December 01, 2014
Tweet

More Decks by Udi h Bauman

Other Decks in Programming

Transcript

  1. Declarative
    Programming
    winning examples
    Udi h Bauman, CloudLock

    View Slide

  2. Declarative
    Programming
    winning examples
    Udi h Bauman, CloudLock
    We’re hiring,
    check us out!

    View Slide

  3. Declarative Programming is
    a form of high-level programming:

    View Slide

  4. Declarative Programming is
    a form of high-level programming:
    telling your software what to do, instead of
    how to do it

    View Slide

  5. Some real-life patterns
    1. “what”-metadata driven
    2. high-level “what”-code
    3. “how”-code abstracted away

    View Slide

  6. 1. “what”-metadata driven
    ● problem: you have many behaviours that only differ in
    parameters or small variants of behaviour

    View Slide

  7. 1. “what”-metadata driven
    ● problem: you have many behaviours that only differ in
    parameters or small variants of behaviour
    ● solution: write metadata & code that derives behaviour
    from metadata

    View Slide

  8. 1. “what”-metadata driven
    ● problem: you have many behaviours that only differ in
    parameters or small variants of behaviour
    ● solution: write metadata & code that derives behaviour
    from metadata
    ● benefit: adding new behaviours now means just adding
    metadata, & in rare cases also overriding
    classes/functions

    View Slide

  9. Example: rollups aggregation

    View Slide

  10. Example: rollups aggregation

    View Slide

  11. 2. high-level “what”-code

    problem: you have many behaviours that
    only differ in the “edges”

    View Slide

  12. 2. high-level “what”-code

    problem: you have many behaviours that
    only differ in the “edges”

    old solution: using inheritance tricks such
    as template method &c

    View Slide

  13. 2. high-level “what”-code

    problem: you have many behaviours that
    only differ in the “edges”

    newer solution: abstract the algorithm to
    declarative high-level code & “chain” the
    overriding behaviour

    View Slide

  14. 2. high-level “what”-code

    problem: you have many behaviours that
    only differ in the “edges”

    newer solution: abstract the algorithm to
    declarative high-level code & “chain” the
    overriding behaviour

    benefit: see the big picture & just the
    relevant details

    View Slide

  15. Example: d3: data-driven documents

    View Slide

  16. Example: d3: data-driven documents

    View Slide

  17. 3. “how”-code abstracted away
    ● problem: if some code addresses
    requirements that are obvious & not specific
    to your app, why should it be there?

    View Slide

  18. 3. “how”-code abstracted away
    ● problem: if some code addresses
    requirements that are obvious & not specific
    to your app, why should it be there?
    ● solution: abstract that code in an underlying
    framework, either yours or someone’s else

    View Slide

  19. 3. “how”-code abstracted away
    ● problem: if some code addresses
    requirements that are obvious & not specific
    to your app, why should it be there?
    ● solution: abstract that code in an underlying
    framework, either yours or someone’s else
    ● benefit: simple, small code just for the
    requirements specific to your app

    View Slide

  20. Example 1:

    View Slide

  21. Example 2: Meteor
    ● if a user is looking at a list of records,
    obviously when a new record is added, the
    user should see it
    ● & if he changes a record, obviously other
    users looking at it should see the
    modification
    ● so why should you implement this?

    View Slide

  22. Example 2: Meteor
    ● So what's declarative here?
    ○ You are left with just declarations:
    ■ What data the server publishes
    ■ What data the client subscribes to
    ■ What data is shown in the UI
    ● See this list of 8 open-source apps written in
    Meteor: http://meteorapps.co
    ○ Except for one they are all well written & worth
    learning from..

    View Slide

  23. Thanks for listening. @dibau_naum_h

    View Slide