Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the Fragile* interfaces in favor of the Failable* interfaces of Apache Commons Lang3 #4

Open
ibbem opened this issue Oct 25, 2022 · 0 comments

Comments

@ibbem
Copy link
Contributor

ibbem commented Oct 25, 2022

The source code of both implementations are almost identical. The only difference is that Functjonal uses Exception as bound and Apache Commons Lang3 (below referred to as Lang3) uses Throwable, which is more general.

I propose to

  • remove the functions package from Functjonal
  • add a Apache Commons Lang3 dependency to Functjonal
  • use Failable* instead of Fragile* everywhere

Theoretically the dependency could be avoided by removing all fragile related functions, but there are still some useful functions which are not provided by Lang3 or interact with Functjonal (e.g. Result.Try).

Pro:

  • Java has a nominal type system, so two identical interfaces are not compatible. That will probably result in pain as soon as some dependency of a project uses Lang3.
  • Lang3 already has failable alternatives for most (probably all, but I didn't check that) of the standard functional interfaces in java.util.function whereas Functjonal only provides a small selection.
  • Lang3 also provides some useful helpers, for example converting a FailableX to an X by rethrowing all exceptions as RuntimeException. It also provides a FailableStream.

Cons:

  • Adding a Lang3 dependency to Functjonal.
  • This is a breaking change for users of Functjonal.

There are currently only two known uses of Functjonal:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant