SlideShare a Scribd company logo
Building Composable
Abstractions:
How to design software to
stand the test of time.
Eric Normand
How do we
structure functional
programs?
Why focus on
abstractions?
What is the process?
Can we see an example?
Conclusions
For the video and transcript
of this presentation,
click here:
https://lispcast.com/oscon-building-composable-abstractions/
Building Composable Abstractions
Aristotelian
Physics
(excerpt)
Ideal speed
Natural place
Natural motion
Unnatural
motion
Building Composable Abstractions
Newton’s Laws of
Motion
1. Inertia
2.
Acceleration
3.
Action-reaction
Force
Mass
Distance
Time
–Eric Normand @ericnormand
“Choice of abstraction matters. There is no
way to refactor Aristotle into Newton.”
Process objectives
• Consistently produces Newtonian abstractions
• Anyone can do
• Fosters collaboration
Inspired by
Conal Elliott’s Denotational Design
Example:
Vector Graphics
System
Canvas
Building Composable Abstractions
Building Composable Abstractions
Building Composable Abstractions
Building Composable Abstractions
Building Composable Abstractions
The Steps
1. Physical metaphor
2. Metaphor exploration
3. Model construction
4. Implementation
–Every experienced programmer, ever
“Don’t just start writing code.
Think about the problem first.”
1. Physical metaphor
2. Metaphor exploration
3. Model construction
4. Implementation
Properties of a Good
Metaphor
Answers most questions
Shared experience
Painting
Stencils
Clay
Projected light
–Eric Normand @ericnormand
“Good metaphors contain answers to
important questions. Different metaphors
might have different answers to the same
questions.”
Shapes in
construction paper
–Eric Normand @ericnormand
“I’ve never met a good abstraction I couldn’t
turn into a good metaphor.”
• Our physical intuition is rich.
• Contain answers to questions.
• Keep you grounded while abstracting.
• Discussable.
Physical metaphor
summary
1. Physical metaphor
2. Metaphor exploration
3. Model construction
4. Implementation
–Every programming teacher ever
“Focus first on the interface, not the
implementation.”
• Cutouts have a color
• Cutouts have a shape
• Overlay order
• Rotation and translation are independent
• Rotation is additive
• Translation is additive
Notes about the
interface
Cutouts have a shape
• Cutout
• Shape
shapeOf(c)
Cutouts have a color
• Cutout
• Shape
• Color
colorOf(c
)
Construct cutouts
• Cutout
• Shape
• Color
• Construct
rect(color, w, h)
circle(color, r)
Overlay order
• Cutout
• Shape
• Color
• Overlay
overlay(a, b) ≠ overlay(b,
a)
What does overlay return?
A cutout?
Cutouts need a shape and color.
–Eric Normand @ericnormand
“Avoid corner cases while you can. Each
corner case is a branch. Branches multiply
when you compose them.”
Overlay order (2)
• Cutout
• Color
• Shape
• Collage
• Overlay
overlay(collage, cutout)
overlay(overlay(col, a), b) ≠ overlay(overlay(col, b), a)
Rotation and translation
independence
• Cutout
• Color
• Shape
• Collage
• Overlay
• Translate
• Rotate
translate(rotate(a, r), x, y) = rotate(translate(a, x, y), r)
Rotation is additive
• Cutout
• Color
• Shape
• Collage
• Overlay
• Translate
• Rotate
rotate(rotate(a, r1), r2) = rotate(a, r1 + r2)
Translation is additive
• Cutout
• Color
• Shape
• Collage
• Overlay
• Translate
• Rotate
translate(translate(a, x1, y1), x2, y2) =
translate(a, x1 + x2, y1 + y2)
too many
concepts
–Eric Normand @ericnormand
“Composition is usually the hardest kind of
operation to implement. We should develop
those first because they will constrain our
design choices.”
Overlay order (3)
• Cutout
• Overlay
overlay(a, b)
overlay(a, b) ≠ overlay(b, a)
Rotation and translation
independence
• Cutout
• Overlay
• Translate
• Rotate
translate(rotate(a, r), x, y) = rotate(translate(a, x, y), r)
Rotation is additive
• Cutout
• Overlay
• Translate
• Rotate
rotate(rotate(a, r1), r2) = rotate(a, r1 + r2)
Translation is additive
• Cutout
• Overlay
• Translate
• Rotate
translate(translate(a, x1, y1), x2, y2) =
translate(a, x1 + x2, y1 + y2)
Construct colors
color(r, g, b)
• Cutout
• Overlay
• Translate
• Rotate
• Color
Construct cutouts
rect(color, w, h)
circle(color, r)
• Cutout
• Overlay
• Translate
• Rotate
• Color
We forgot to draw
• Cutout
• Overlay
• Translate
• Rotate
• Color
• Draw
draw(cutout)
Step 2 Summary
• Sketch out operations and relationships between
operations.
• Focus on composition first.
• No corner cases.
1. Physical metaphor
2. Metaphor exploration
3. Model construction
4. Implementation
We need
representations
• Cutout
• Overlay
• Translate
• Rotate
• Color
• Draw
Number
String
Object
Array
Function
…
–Eric Normand @ericnormand
“Choose constructs that have the properties
you’re looking for.”
Functions
outpu
t
inputs
(things that change)
Functions
outpu
t
inputs
(things that change)
variables in
environment
(things that don’t change)
Colorconstructor
function things that don’t change
nothing that changes
–Eric Normand @ericnormand
“If you really want to see how an abstraction
composes, represent it as a function.”
Rectangles
translation and rotation
can change
color and
shape
do not change
call color
function
cutout is a function
Circles
Translation
cutout is a function
call cutout with new translation
Rotation
cutout is a function
call cutout with new rotation
Overlay
draw!
Building Composable Abstractions
Building Composable Abstractions
Overlay
–Eric Normand @ericnormand
“Revisit your physical metaphor.
It contains the answers.”
Overlay with center
Building Composable Abstractions
Step 3 Summary
• Choose existing constructs that have properties.
• Revisit the metaphor if there are problems.
1. Physical metaphor
2. Metaphor exploration
3. Meaning construction
4. Implementation
–Well-meaning OOP programmers everywhere
“Just use a class.”
Conclusions
Process objectives
• Consistently produces Newtonian abstractions
• Anyone can do
• Fosters collaboration
Corollaries
• Know your domain (metaphor)
• Know your language (meaning)
Is your system Aristotelian or
Newtonian?
Eric Normand
Follow Eric on:
Eric Normand @EricNormand
eric@lispcast.comlispcast.com

More Related Content

PPTX
PR-122: Can-Creative Adversarial Networks
PPT
lecture-9-online WORK PART UNIFORMITY IN
PPT
lecture-9-online.pptVHVHJBJBJBBJBJBBBBBHHBH
PPT
september18.ppt
PPTX
Variables and Statements
PPT
affine transformation for computer graphics
PPT
Lecture 9-online
PPTX
Module_2_rks in Artificial intelligence in Expert System
PR-122: Can-Creative Adversarial Networks
lecture-9-online WORK PART UNIFORMITY IN
lecture-9-online.pptVHVHJBJBJBBJBJBBBBBHHBH
september18.ppt
Variables and Statements
affine transformation for computer graphics
Lecture 9-online
Module_2_rks in Artificial intelligence in Expert System

Similar to Building Composable Abstractions (20)

PDF
Editors l21 l24
PDF
stable_diffusion_a_tutorial, How stable_diffusion works, build stable_diffusi...
PPTX
Digital System Design.pptx by the police by the
PDF
Clojure intro
PPTX
06 image features
PPTX
MATLAB & Image Processing
PPTX
My pp tno sound
PPTX
2D Transformation.pptx
PDF
5_Geometric_Modeling.pdf
PPTX
lec04_harris_for_web computer vision and
PPTX
Benoit fouletier guillaume martin unity day- modern 2 d techniques-gce2014
PPTX
VHDL and Cordic Algorithim
PPT
2.1 Functions and Their Graphs
PPT
october9.ppt
PDF
Teaching Constraint Programming, Patrick Prosser
PPT
november6.ppt
PDF
Object Recognition with Deformable Models
PPT
Ciencias de la computación, Gráficos por computadora.
PPTX
Lecture_07_InterestPoints_computer_vision.pptx
PPTX
React Native Performance
Editors l21 l24
stable_diffusion_a_tutorial, How stable_diffusion works, build stable_diffusi...
Digital System Design.pptx by the police by the
Clojure intro
06 image features
MATLAB & Image Processing
My pp tno sound
2D Transformation.pptx
5_Geometric_Modeling.pdf
lec04_harris_for_web computer vision and
Benoit fouletier guillaume martin unity day- modern 2 d techniques-gce2014
VHDL and Cordic Algorithim
2.1 Functions and Their Graphs
october9.ppt
Teaching Constraint Programming, Patrick Prosser
november6.ppt
Object Recognition with Deformable Models
Ciencias de la computación, Gráficos por computadora.
Lecture_07_InterestPoints_computer_vision.pptx
React Native Performance
Ad

More from Eric Normand (9)

PDF
You are in a maze of deeply nested maps, all alike
PDF
The elements of a functional mindset
PDF
All I Needed for Functional Programming I Learned in High School Algebra
PDF
Lies My OO Teacher Told Me
PDF
What is Functional Programming?
PDF
Functional Programming for Business
PDF
A Theory of Functional Programming LambdUp
PDF
Testing stateful, concurrent, and async systems using test.check
PDF
ClojureScript: I can't believe this is JavaScript
You are in a maze of deeply nested maps, all alike
The elements of a functional mindset
All I Needed for Functional Programming I Learned in High School Algebra
Lies My OO Teacher Told Me
What is Functional Programming?
Functional Programming for Business
A Theory of Functional Programming LambdUp
Testing stateful, concurrent, and async systems using test.check
ClojureScript: I can't believe this is JavaScript
Ad

Recently uploaded (20)

PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPTX
CH1 Production IntroductoryConcepts.pptx
DOCX
573137875-Attendance-Management-System-original
PPTX
UNIT 4 Total Quality Management .pptx
PPTX
OOP with Java - Java Introduction (Basics)
PDF
Digital Logic Computer Design lecture notes
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
additive manufacturing of ss316l using mig welding
PPTX
Construction Project Organization Group 2.pptx
PPTX
Lecture Notes Electrical Wiring System Components
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PPT
Mechanical Engineering MATERIALS Selection
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PPTX
Sustainable Sites - Green Building Construction
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
CH1 Production IntroductoryConcepts.pptx
573137875-Attendance-Management-System-original
UNIT 4 Total Quality Management .pptx
OOP with Java - Java Introduction (Basics)
Digital Logic Computer Design lecture notes
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
Automation-in-Manufacturing-Chapter-Introduction.pdf
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
additive manufacturing of ss316l using mig welding
Construction Project Organization Group 2.pptx
Lecture Notes Electrical Wiring System Components
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
Mechanical Engineering MATERIALS Selection
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
Sustainable Sites - Green Building Construction

Building Composable Abstractions