Is this a correct approach to functional way of bu...
# functional
j
Is this a correct approach to functional way of building an object when multiple transformations/calls are necessary? Should I use a different name for each functions assuming it could be 10x more “”transformation functions” or more intermediate parameters?
Copy code
data class SomeClass(
    a: A,
    b: B,
    c: c,
)

fun buildSomeClass(
    result1: ResultFromHttp1,
    result2: ResultFromHttp2,
): SomeClass = buildSomeClass(
    intermediate1 = result1.transfom()
    intermediate2 = result2.transform()
)

internal fun buildSomeClass(
    intermediate1: IntermediateType1,
    intermediate2: IntermediateType2,
) = SomeClass(
    a = intermediate1.a,
    b = intermediate2.b,
    c = intermediate2.c,
)

internal fun ResultFromHttp1.transform(): IntermediateType1 = ...
internal fun ResultFromHttp2.transform(): IntermediateType2 = ...