Scott Shipp wrote:Since they are the hot new thing, it feels like everyone's talking about lambdas all the time. It's almost as if lambdas can be used to solve any problem. In writing Java 8 Lambdas: Pragmatic Functional Programming, did you find any areas where lambdas are bluntly the wrong tool for the job? What were they? Why do lambdas fail in these areas?
Thanks for the question. I won't say that there's a clear-cut line where lambdas are right and where they are wrong. Its more like there's a spectrum where they are best suited at one end and worst suited for use at the other end. Lambdas are best suited to situations where you want to write short, pure, simple methods and pass them around into other code. The further away from that ideal you get the more I would choose not to use them. So the larger the method, the more it mutates state and the more complex the logic, the better off you are using regular methods.