Uncle Bob mentions in his book "Clean Code" that "[f]unctions should do one thing [...] only" and advocates that a method should stick to one abstraction level (I'd call it flight level). I struggle a bit on how to do that in reactive programming, though.
Say I've got an expensive database call. And that depending on a property on the objects it returns, I want to process these objects (very) differently.
I have seen pople use the groupBy(...)
operator - but that means one method (in which the groupBy
is used) usually ends up doing multiple things (in both senses: tasks and flight levels) - at least in the examples.
I've thought about splitting the stream (a related question with an example is on SO), but it doesn't feel quite right, either.
So I was wondering if there is any literature (blog posts, articles, books) or good examples on e.g. GitHub on the topic of how to break a reactive stream up into building blocks so that it conforms to the "do one thing" principle? (I guess usually you'd just open up new subscriptions, but when the source is expensive to obtain, that's not a good way to do it, either, I guess.)
Or if there's a different way to tackle the issue (from splitting the stream)?