|
|
|
|
|
by lamontcg
820 days ago
|
|
> Developers don't like to think about abstractions and naming is a known hard problem. People pick this up and now everything is easy. Every name becomes: DoThis, DoThat, DoThisOtherThing and only answers to `call`. No need to think! This 'framework' doesn't require that though: def double_number(r) = r.continue(r.value * 2)
def add_one(r) = r.continue(r.value + 1)
def square_number(r) = r.continue(r.value ** 2)
pipeline = Pipeline.new do |pl|
pl.step method(:double_number)
pl.step method(:add_one)
pl.step method(:square_number)
end
Just methods, with no need to implement call() because that is what a method/proc/lambda in ruby implements. In other languages like C# you could have an API that can take a Func<Result, Result> so that you can just pass delgates/lambdas/methods to it. And adding a bit more DSL could make the construction of the pipeline even less verbose.You can use this without going full-Java and creating a dozen (or a hundred) 5-line classes in different files. |
|