react by performing some logic in a click listener • Data loaded from an HTTP request • We react by displaying parsed data in a View • IOException thrown while doing I/O work • We react by displaying error message, logging error, etc.
• Ordering of callback events can be hard to follow / visualize • Handling multiple threads can be difficult, or at best verbose • Error handling becomes verbose and reduces readability
functional programming • Gives predictable results without worrying about “side-effects” (state) • Logic for a stream is concentrated in one place • Logic for each function can still be split out where it makes sense
the previous code sample • Logic is concise and easy to follow • Error handling is simplified • Imagine if yet another service call was needed in this chain