Devoxx - filter, partition and offset

Stephen Colebourne scolebourne at
Wed Apr 3 04:36:38 PDT 2013

It didn't come up in the Devoxx lab, but I found the filter() method
confusing when reading code in the talks. It was not obvious to me
whether it was filtering in or out.

I was then surprised that there was only one method in the API for
filtering, rather than two - one to remove and one to retain. While
clearly they are a logical not, in code readbility terms its typically
a lot clearer.

Perhaps keep() and reject()? I'm sure there are other names, but
filter alone feels very unclear. (I can't remember which it is now).

The partitioningBy method also looked very confusing. My take on
parttition as a concept was to split a list into two lists. Reading
the documentation and the method signature didn't tell me what the
method does at all. I certainly didn't grok the boolean.

With an API contaiing limit(), my database work expected me to see a
matching offset(). I understand that there are issues with parallel,
but it looked like an omission.


On 3 April 2013 09:12, Richard Warburton <richard.warburton at> wrote:
> Last week at DevoxxUK we ran a brief lambdas hackday.  People were
> encouraged to focus on the collectors component of the API through setting
> a few problems to solve.  I appreciate its a bit late in the game as far as
> API changes, but some of these issues are fixable through
> documentation/improved compiler error changes rather than API changes.
> 1. No one complained about the move from “into(new ArrayList<Foo>());” ->
> “collect(toList())” when you explained that the change had been made.
>  However, people didn’t naturally find Collectors.toList() and they did
> express frustration around that.  At least one request for an abbreviated
> toList() method on a stream - more for findability/fluency reasons rather
> than brevity of code.
> 2. ToIntFunction, ToDoubleFunction etc. are all usable with flatMap, but
> the naming confused people as to why.
> 3. Several people requested a way to transform a boxed stream into an
> unboxed stream.  Its pretty easy to go the other way around, but there
> didn’t seem to be any utility methods for making the boxed -> unboxed
> transformation.
> 4. People found “groupingBy” to be a hard conceptual leap.  We had set an
> exercise where people were asked to count the frequency of words in a
> document, in order to force them to use it.
> a. Quite a few people didn’t initially look for a function that collects a
> stream into a map.
> b. When you suggest that they should look for that, they didn’t look for
> something called “groupingBy”.
> c. They did get the concept once you bring up SQL.  With hindsight I wished
> I had enquired about how many people had used LINQ.
> d. People then didn’t grok that they needed to use the multiple argument
> overload of groupingBy, with a reducingBy, in order to complete the task.
>  I suspect that this method needs more documentation examples in order to
> be easily understandable by people.
> 5. People are beginning to get confused by old documentation on the
> internet being out of date.  I hadn’t seen this in previous hackdays.  Even
> an article in the latest Java Magazine is out of date due to the API moving
> so much recently, and so is the official tutorial:
>  Probably not a long term concern - but might be a concern for the first
> few months.
> 6. If anyone else runs this kind of thing and they are a day-to-day eclipse
> user, word of advice to make sure you know how to set the preferred JVM
> location in netbeans and intellij before you run the event!
> Thanks to everyone that attended, and especially to Stuart Marks, Maurice
> Naftalin, Graham Allan and John Oliver for helping out with running the lab.
> There’s a full link with code that people wrote and pasted at, and it also
> contains some more comments by people:
> regards,
> *
>   Richard Warburton
>   @RichardWarburto <>

More information about the lambda-dev mailing list