Slide 1

Slide 1 text

Declarative Programming winning examples Udi h Bauman, CloudLock

Slide 2

Slide 2 text

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

Slide 3

Slide 3 text

Declarative Programming is a form of high-level programming:

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

Example: rollups aggregation

Slide 10

Slide 10 text

Example: rollups aggregation

Slide 11

Slide 11 text

2. high-level “what”-code ● problem: you have many behaviours that only differ in the “edges”

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

Example: d3: data-driven documents

Slide 16

Slide 16 text

Example: d3: data-driven documents

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

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

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

Example 1:

Slide 21

Slide 21 text

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?

Slide 22

Slide 22 text

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..

Slide 23

Slide 23 text

Thanks for listening. @dibau_naum_h