Imagine you have a chain of functions calls, in which each function is taking the previous function's output as input for the next calculation in the chain.
Make an assumption that you are leading the infra scope, which means you are defining the process chain and protocol, but you have a group of users that are responsible to implement each cube of the chain (I.e implementation of functions
C and so forth).
Assume we have already a given flow like
A->B->C->D, now imagine that function
A sometimes need to return a
dictionary and sometimes
pandas dataframe as input, this is requirement came from the users, and I think quite break common programming paradigms.
In my opinion, this can have serious inconsistency issues, errors and less testable code.
I would like to hear your thoughts regarding this as a concept
Do you think it is reasonable to return different value type from function according to configuration and having protocol in which each cubes in chain may not talking always on the same protocol? (Discliamer: We are using
I tend to see this equivalent to the ability, for example, to populate function parameter function with different types for the same parameter let say (I.e sometimes int sometimes dict) at different function calls - which is wrong.
Although a dynamic type language might let you do it, it's doesn't necessarily mean you should do it, and it may be considered as a bad practice or even abuse of the ability.
Even in python the use of dynamic parameters passing (*args, **kwargs) should be used wisely and in a limited way and only when needed for example here