Skip to main content
Code Review

Return to Answer

Your code is fluent, and not really functional.

It solves a problem that Java’s try block doesn’t return a value, but I don’t see a benefit of it over extracting the try-catch block into a separate method/lambda.

To make it more functional, you need to allow operating on the TryTry<T> object on a higher level. For example, transforming the result before the code is executed. The first step would be extracting the interface. Is it Supplier<T>?

Try writing something similar to TryTry<T> from Vavr.

(Rant mode) This obsession with fluentism and calling it „functional" is in my opinion a sign of a novice Java 8 programmer, leading to monstrocities of flatMappedflatMapped, orElseGetted OptionalorElseGettedOptional constructs. (/Rant mode)

Your code is fluent, and not really functional.

It solves a problem that Java’s try block doesn’t return a value, but I don’t see a benefit of it over extracting the try-catch block into a separate method/lambda.

To make it more functional, you need to allow operating on the Try object on a higher level. For example, transforming the result before the code is executed. The first step would be extracting the interface. Is it Supplier<T>?

Try writing something similar to Try from Vavr.

(Rant mode) This obsession with fluentism and calling it „functional" is in my opinion a sign of a novice Java 8 programmer, leading to monstrocities of flatMapped, orElseGetted Optional constructs. (/Rant mode)

Your code is fluent, and not really functional.

It solves a problem that Java’s try block doesn’t return a value, but I don’t see a benefit of it over extracting the try-catch block into a separate method/lambda.

To make it more functional, you need to allow operating on the Try<T> object on a higher level. For example, transforming the result before the code is executed. The first step would be extracting the interface. Is it Supplier<T>?

Try writing something similar to Try<T> from Vavr.

(Rant mode) This obsession with fluentism and calling it „functional" is in my opinion a sign of a novice Java 8 programmer, leading to monstrocities of flatMapped, orElseGettedOptional constructs. (/Rant mode)

added 18 characters in body
Source Link

Your code is fluent, and not really functional.

It solves a problem that Java’s try block doesn’t return a value, but I don’t see a benefit of it over extracting the codetry-catch block into a separate method/lambda.

To make it more functional, you need to allow operating on the Try object on a higher level. For example, transforming the result before the code is executed. The first step would be extracting the interface. Is it Supplier<T>?

Try writing something similar to Try from Vavr.

(Rant mode) This obsession with fluentism and calling it „functional" is in my opinion a sign of a novice Java 8 programmer, leading to monstrocities of flatMapped, orElseGetted Optional constructs. (/Rant mode)

Your code is fluent, and not really functional.

It solves a problem that Java’s try block doesn’t return a value, but I don’t see a benefit of it over extracting the code into a separate method.

To make it more functional, you need to allow operating on the Try object on a higher level. For example, transforming the result before the code is executed. The first step would be extracting the interface. Is it Supplier<T>?

Try writing something similar to Try from Vavr.

(Rant mode) This obsession with fluentism and calling it „functional" is in my opinion a sign of a novice Java 8 programmer, leading to monstrocities of flatMapped, orElseGetted Optional constructs. (/Rant mode)

Your code is fluent, and not really functional.

It solves a problem that Java’s try block doesn’t return a value, but I don’t see a benefit of it over extracting the try-catch block into a separate method/lambda.

To make it more functional, you need to allow operating on the Try object on a higher level. For example, transforming the result before the code is executed. The first step would be extracting the interface. Is it Supplier<T>?

Try writing something similar to Try from Vavr.

(Rant mode) This obsession with fluentism and calling it „functional" is in my opinion a sign of a novice Java 8 programmer, leading to monstrocities of flatMapped, orElseGetted Optional constructs. (/Rant mode)

Source Link

Your code is fluent, and not really functional.

It solves a problem that Java’s try block doesn’t return a value, but I don’t see a benefit of it over extracting the code into a separate method.

To make it more functional, you need to allow operating on the Try object on a higher level. For example, transforming the result before the code is executed. The first step would be extracting the interface. Is it Supplier<T>?

Try writing something similar to Try from Vavr.

(Rant mode) This obsession with fluentism and calling it „functional" is in my opinion a sign of a novice Java 8 programmer, leading to monstrocities of flatMapped, orElseGetted Optional constructs. (/Rant mode)

lang-java

AltStyle によって変換されたページ (->オリジナル) /