clojuredesign-podcast

Discussions around the Functional Design in Clojure podcast - https://clojuredesign.club/
lodin 2019-09-02T20:35:56.043800Z

@neumann I have a question regarding your triangle example from episode 42, because I feel like I am missing something. Adding fields with derived data is something I've heard other people talk about as well. What is the benefit of enriching the map with fields and then extract that value (e.g. perimeter or area), over just having a function that computes and returns the value? So (perimeter triangle) or (perimeter (points triangle)) instead of (with-perimeter triangle) and then (:perimeter triangle).

neumann 2019-09-06T15:00:51.021100Z

@lodin.johan Sorry for the slow reply. I just want to let you know that we picked up this question for our episode that comes out later today. There are a couple of different reasons, but one of the main reasons is performance. If you just need the area here and there, you can compute it on the fly with a function. If you want to reference the area over and over (especially in some sort of map/`filter`/`reduce` statement), it's better to have a proper derived field for it.