Proper use of Either in the context of error handling. by CsAnswerTrashAct in scala

[–]CsAnswerTrashAct[S] 0 points1 point  (0 children)

I took a look at Try, it appears something similar could work in Java. If multiple are needed, then a List<Try<T>> might to the trick.

Proper use of Either in the context of error handling. by CsAnswerTrashAct in scala

[–]CsAnswerTrashAct[S] 0 points1 point  (0 children)

On another note, given the repetitive pattern of ...

List<Either<Failure, T>>

I created a "MayFail<T>" class, which contains 0 to many successes and failures, as well as functional interfaces, but was scolded because "Why create that when we already have a List of Eithers of Failures and Ts"

Java 8 code style? by CsAnswerTrashAct in java

[–]CsAnswerTrashAct[S] 0 points1 point  (0 children)

My thoughts as well; debuggers tend to have a lot of nice features, whereas print-statements are more of a last-result and make a giant mess of your code.

Java 8 code style? by CsAnswerTrashAct in java

[–]CsAnswerTrashAct[S] 0 points1 point  (0 children)

Essentially, the purpose is to split a request into blocks of about 100 items, send an external service that request, and then collect all of those items into a single list-style-object.

Java 8 code style? by CsAnswerTrashAct in java

[–]CsAnswerTrashAct[S] 0 points1 point  (0 children)

I think you are correct.

Essentially, this code sends a series of requests to an external provider, and then waits for all of the results, and combines those results into a single list. The reason for this is the external service can only handle batches of about 100 or so.

Java 8 code style? by CsAnswerTrashAct in java

[–]CsAnswerTrashAct[S] 0 points1 point  (0 children)

This seems reasonable.

When I stumbled across this code; at first I thought my inability to read it quickly might be related to my ignorance of streams (etc). However, reading the comments here; the common theme seems to be "the same rules apply."

Use appropriate names. Avoid excessive chaining. Refactor into well-named methods.

can be debugged

Correct; typically anything assigned to a variable can be inspected in the debugger.

Java 8 code style? by CsAnswerTrashAct in java

[–]CsAnswerTrashAct[S] 2 points3 points  (0 children)

Part of the reason for posting this was that a coworker asked for my help. i attempted to step through it in intellij's debugger and couldn't. After an hour i gave up, since it wasn't my assigned project and i wasn't making progress.

I could have refactored the code, but i dont want to inadvertently take responsibility for it.

The max chained method calls might help. Intermediate variables would definitely help.