Just Eat GJ Kooijmans Aug 23, 2021

Best Practices for Writing Compose Code

Article Summary

GJ Kooijmans from Just Eat Takeaway compares writing software to Bruce Springsteen's E Street Band. Both succeed by composing simple parts into harmonious wholes—but most developers struggle with the composition part.

This article breaks down function composition principles using JavaScript examples, drawing from Eric Elliott's book 'Composing Software.' Kooijmans argues that learning to compose code properly is the difference between maintainable software and projects held together with duct tape.

Key Takeaways

Critical Insight

Mastering function composition makes your code structured, scalable, and understandable by breaking complex problems into simple, composable solutions.

The article includes a practical refactoring example that transforms messy price calculation code into a clean, one-line pipeline.

About This Article

Problem

When developers work with composed functions, they can't see the intermediate values. This makes it hard to figure out where calculations break down in multi-step pipelines.

Solution

GJ Kooijmans built a trace utility function that logs values between composed functions. Developers can now inspect outputs at each step without breaking the composition chain.

Impact

Using pipe and trace utilities keeps code concise and easier to read. Other developers spend less mental effort understanding how the functions connect.