0

There are some (let's say 20) concrete implementations of the FunctionalInterface Function< Input, Output> addressing isolated aspects of my business logic.

A combination of some of these concrete implementations depict the behavior of my business logic. More than one behavior is possible based on the implementations selected and the chaining of them.

This model works as long as the chaining is linear.

Now, there are two more requirements:

  1. Chain with branching (tree), i.e.

               F3 -> F5
             /
    F1 -> F2 
             \ 
               F4 -> F6
    
  2. Chain that parallelizes and then merges (DAG), i.e.

               F3 -> F5
             /          \
    F1 -> F2              F7 -> F8
             \          /
               F4 -> F6 
    

I can force-fit the above two requirements in the linear model by defining a composite Function that has the linear chains, i.e.

  F1 -> F2 -> F3`, 

where F3` is the implementation that looks like:

if (F2.result) {
    F3 -> F5
} else {
    F4 -> F6
}

A better approach would be to introduce constructs like BRANCH, PARALLEL, JOIN to address the above, which is too much work.

Essentially, the problem above could be solved by a TaskGraph execution framework, where each of the above cases (linear, tree, DAG) could be modeled.

Are there any frameworks that provide this functionality already ?

The use-case is primarily concerned with reusability of code within a single process. The functions are simply modularized code addressing a single concern, for example, ReadFromDB, TransformData, EnrichData, PublishToDB etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.