Skip to content
0:00 / 0:00

#defunctionalization#refunctionalization#refactoring

The Best Refactoring You’ve Never Heard Of

Compose Conference

2.9K subscribers • 31 videos on Hallway

YouTube
  • Recommended by 2 people: 2 in engineering communities.
  • Presented by James Koppel

Advanced. Deep dive for people who know the field.

16K views7 years ago2 recommendations

Software designProgramming languagesRefactoring and legacy codeFunctional programmingDesign patterns

James Koppel explains defunctionalization and its inverse, showing how to mechanically transform designs between functional and object-oriented patterns.

Compose NYC 2019 Speaker: James Koppel Every problem can be solved by many designs. Often the relation between two designs is that one is a transformation of another. When we understand how to mechanically transform designs, we can more easily explore the design space, and effortlessly identify the tradeoffs. So, what do these design changes have in common? * Letting a search procedure take an arbitrary filter function, instead of a fixed set of options * Changing a program using blocking I/O to non-blocking I/O with an event loop * Letting a user stop in the middle of an action — and resume it after a server reboot Answer: They’re all instances of a transformation called “defunctionalization” or its inverse, “refunctionalization.” Come learn how it works, and learn to recognize when a proposed design change is just an instance of this general technique. In doing so, you’ll learn how the tradeoffs between designs can be boiled down into a single slogan: refunctionalized is more open, defunctionalized is more inspectable. As a plus, you’ll also learn how defunctionalization is the oldest technique to compile functional languages.

Why it's here

2 people recommend this

What people say. Recommended as a great explanation of defunctionalization and how it relates to design patterns like the command pattern.

u/mamcxin r/ProgrammingLanguages • Recommends

On “What is the best way to implement staging?”

This could help: https://www.joachim-breitner.de/blog/778-Don’t\_think,\_just\_defunctionalize [video It shows a kind of transformation that could make this work. In the other hand, probably TCL/APL/Forth style languages are the easiest to pull this kind of tricks

u/strongly-typedin r/ocaml • Recommends

On “Command object pattern in FP”

The command object design pattern sounds a lot like defunctionalization to me. James Koppel gave a great talk about that here: link to this video