DEV Community

Discussion on: Let's talk about STREAMS !!

the_unconventional_coder profile image
ABHINAVA GHOSH (he/him) Author • Edited on

Glad you liked the article.
But just one thing to point out that writing code via streams is not necessarily for "being cool" but streams actually make your code more presentable and understandable. Compared to " spaghetti code" , and traditional for loops and etc , streams make the code quite compact and readable, even if they do not always give better performance compared to traditional style.

And yes coming to the point of parallelStream vs normal streams , yes i agree that one should use parallelStream very cautiously , as it may lead up to higher resource consumption. But i dont think junior devs face many situations where they are to take a decision between what to choose, but anyway i provided links for anyone wanting to dive deep.

190245 profile image

I would say that Streams offers no more clarity of code than well designed OO classes. Nothing about well thought out OO gives us "spaghetti."

Indeed, use of map() is probably a code smell that's tells us the method is doing more than one thing (and is a violation of SRP). Unless, of course, immediately after map() you call collect(), and you're inside a Transformer or Adaptor pattern.

Some comments have been hidden by the post's author - find out more