(this question is written from a functional javascript point of view)
say you have some pure functions:
function a (arg) {
...
return result
}
function b (arg) {
...
return result
}
function c (arg) {
...
return result
}
And in your business logic, you are looping through a list of data and processing each datum
for (const datum of data) {
const { preA, preB, preC } = datum
const postA = a(preA)
const postB = b(preB)
const postC = c(preC)
...
}
Say that it's not just three function calls in this for loop, but dozens, and you want to encapsulate this set of functions into some outer function:
function outerFunction(datum) {
const { preA, preB, preC } = datum
const postA = a(preA)
const postB = b(preB)
const postC = c(preC)
...
return {
postA,
postB,
postC,
...
}
}
And your business logic now looks like:
for (const datum of data) {
const { postA, postB, postC, ... } = outerFunction(datum)
...
}
How would you describe this outer function? facade function? wrapper function? helper function? orchestrator function?
Would you call it something else? Would you approach this code in a different way?
mapfunction rather than iteration.data.map(outerFunction).reduce(somethingElse)(or something more specific thanreduce)