• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Falling in Love With Streams

 
Saloon Keeper
Posts: 1606
52
Eclipse IDE Postgres Database C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So I have these two conflicting feelings.

Choices, choices, choices!

There are so many ways to express non-trivial Streams operations, a lot of methods and options to learn.

I think I realized tho, the third-best way of doing something is still more readable to me than pre-Java-8 ways of doing stuff, and only looks bad when placed next to one of the "even better ways" of doing it!

Following along with "Lambdas and Streams Master Class Part 2 by José Paumard, Stuart Marks" my version is:
 
Jesse Silverman
Saloon Keeper
Posts: 1606
52
Eclipse IDE Postgres Database C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Doh!  Proving my own point, I forgot what Rob had taught me a couple of weeks ago about "Ya know, you can do that without any use of Arrays if you know how..."

I think this is even nicer, actually, but again, the clumsier thing I came up with under pressure while watching a workshop taught by super-experts was still more readable than how I always did things a few months ago.  But yeah, this is a bit nicer, definitely Streamier, and possibly sometimes faster (but who cares):



I tried using a method reference instead of the static method call in a lambda, but did not find it increased the readability for me.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic