DRYing the world

Ingmar Dasseville - VIGOR day 2015

DRY

on't

epeat

ourself

Draw A Triangle

Draw A Square

GoUp(1)
Rotate(120)
GoUp(1)
Rotate(120)
GoUp(1)
Rotate(120)
GoUp(1)
Rotate(90)
GoUp(1)
Rotate(90)
GoUp(1)
Rotate(90)
GoUp(1)
Rotate(90)

We Enjoy Typing

WET code

DRYing the code

polygon(n) {
    for (int i = 0 ; i < n ; i++) {
        GoUp(1)
        Rotate(360/n)
    }
}

DRYing

with loops

polygon(n) = replicateM n (do 
                        GoUp(1) 
                        Rotate(360/n)
            )

DRYing with higher order functions

?

Does this sequence of actions correspond to a polygon?

Knowledge Representation

  • Knowledge: Polygon(n) = a set of lines
  • Problem: 
    • Get the set of lines for a certain N
    • Check if there exist an N such that the Polygon(N) is my set of lines

Problem Solved?

As long as you're not reading the fine print, it is.

IDP / ASP / ...

{
	∀ x y: Reachable(x,y) ↤ Edge(x,y).
	∀ x y: Reachable(x,y) ↤ ∃ z: Reachable(x,z) 
                                    & Reachable(z,y).
}

in 80%* of the theories

*non-scientific number

Proposed Solutions

C-style macros

Our Solution

Conclusion

When creating a language, enable the programmer to program DRY!

  • Implementation
  • Libraries
  • Even more abstractions!
My question for you:

DRY Knowledge Representation 

 

DRY Software Engineering

Made with Slides.com