In recent days, I've seen a bit too much of this: someCollection .stream() .map(e -> someFunction(e)) .collect(Collectors.toList()) .subList(0, 2); Something is very wrong with the above example. Can you see it? No? Let me rename those variables for you. hugeCollection .stream() .map(e -> superExpensiveMapping(e)) .collect(Collectors.toList()) .subList(0, 2); Better now? Exactly. The above algorithm is O(N) … Continue reading A Basic Programming Pattern: Filter First, Map Later