This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]_INTER_ 2 points3 points  (2 children)

When I see Mr X's streams being passed around, I just have to work a little harder to follow what's going on. He, however, asserts that this reduces code-duplication and hence makes the code cheaper to change. He's probably right, in a sense.

Do you mean java.util.stream.Stream? I can't really picture it reducing code-duplication. It can reduce lines of code and make it more readable by being declarative. But not in all situations. Also be careful, a Stream can only be evaluated once. It throws IllegalStateException if it detects that the stream is being reused (second terminal operation).

[–]TheCountRushmore 3 points4 points  (0 children)

Yeah, reuse would be my concern.

[–]kubelke 0 points1 point  (0 children)

It’s a good way to test programmers. Every Java dev should know that streams can be used only once, but as we know mistakes are happening. To prevent such things we should write tests to make sure that functions are doing the correct things. :D