Sveriges mest populära poddar

Functional Design in Clojure

Ep 097: Application of Composition

29 min • 2 november 2023

Each week, we discuss a different topic about Clojure and functional programming.

If you have a question or topic you'd like us to discuss, tweet @clojuredesign, send an email to [email protected], or join the #clojuredesign-podcast channel on the Clojurians Slack.

This week, the topic is: "composing your application". We get a handle on bringing I/O resources together in an application.

Our discussion includes:

  • What is a "handle"? Why is it called that?
  • More puns!
  • How do you handle I/O handles?
  • How do you keep the pure and side-effecting parts away from each other?
  • Managing and organizing application components.
  • What is a framework vs a library?
  • "Injection style" vs "singleton style".
  • How far down the call stack should handles travel?
  • Figuring out a start-up order and a shut-down order.
  • How obtaining a resource can negatively affect composition.
  • Separating the knowledge of finding a resource vs using a resource.
  • The concept of an "application index".
  • Why all this matters for long-term maintenance.
  • Using feature flags.
  • The two developers on every software project.
  • What is the "band-aid test"?

Selected quotes:

  • "If a program does a bunch of computation, but it doesn't have any I/O, did it do anything?"
  • "Handles inherently are going to hurt you. You don't even have a hold on the whole thing. You have a little bit that you can use to to access that external system."
  • "I visualized an axe or a knife. You have a handle, but you have to watch out for what the handle is connected to!"
  • "In Clojure, I think of frameworks as an integration between your code and the purpose of that framework as opposed to the foundational layer that glues your whole world together."
  • "Even in OO, it's a smell if I/O handles travel too far and wide!"
  • "Lots of assuming!"
  • "Sometimes ad hoc is confused with flexibility. You didn't have to think about it, so it felt flexible, but it just happened."
  • "Composition is about being able to use things in multiple ways."
  • "If you are accessing a singleton state from a function, you are no longer side effect free."
  • "Why would I ever save anything anywhere other than the place the application has configured as its database?"
  • "Have you ever had a physical "dead tree" book?"
  • "Where are all the components?"
  • "With the index style, you have a clear delineation of all the parts of the software and how they're connected together."
  • "Whenever you start using a library or framework, you are hopefully solving a problem, but you're also inviting complexity in. You have to be wary of what it allows you to do, and what it allows future developers to do."
  • "If you pull that band-aid off, how many little hairs are going to come off with it? How badly is it going to hurt?"
  • "One of the tests of composability is the surface area of contact. More is not better!"

Links:

Förekommer på
00:00 -00:00