3 ms·
If you name your functions and transducers well, you tell the reader what’s being done to the data. If you name your intermediate data structures well, you tel
by skrebbel 3y ago
If you name your functions and transducers well, you tell the reader what’s being done to the data.
If you name your intermediate data structures well, you tell the reader what the data means.
Often, the transformations have generic names such as “unique” or “removeEmpty”, but the variables can get domain-specific names such as “validOrders” or “paidAccounts”.
I’m a big fan of designing code in a datastructure-first way. If you get the datastructures right, the code itself is often easy to write and easy to read. This matches FP languages really well (eg immutability), but it doesn’t match long fluent chains/pipes of maps, filters and reduces well at all.
- bcrosby95 3y agoYou can name anonymous functions so your transformations can still have a domain related name associated with it, even if you're using standard library ones.
- skrebbel 3y agoIf you’re making a local anonymous function that you call in one place, just so that a generic function gets a more domain specific name, then you might as well just assign the result to a named variable, right? It’s the same benefit with less indirection.