stojan
06/17/2020, 4:19 PMraulraja
06/17/2020, 4:32 PMraulraja
06/17/2020, 4:32 PMstojan
06/17/2020, 4:39 PMraulraja
06/17/2020, 4:40 PMstojan
06/17/2020, 4:42 PMraulraja
06/17/2020, 4:47 PMraulraja
06/17/2020, 4:49 PMstojan
06/17/2020, 7:45 PMnull
. People new to FP starting with Arrow would probably start using it by using Option
/`Try` /`Either` So newcomers to FP would use Option
instead of null
Try
was deprecated some time ago, and will be removed. And the migration story there could have been better. I know some people who didn't understand the reasoning behind this, and actually moved away from Arrow because of it
Now back to Option.
list.first()
throws an Exception in case of an empty list. Break RT and comes with all the drawbacks from it.
list.firstOption()
is RT and comes with all the benefits. It is significantly better than first()
list.firstOrNull()
is even better. No wrapping, more idiomatic and probably more performant. It is better than firstOption()
but not by much. Both are RT and compose really well.
Removing all usages of Option
and replacing them with Nullable types might take significant effort in a larger codebase for exactly 0 business value. If performance was critical people would probably not use Option
in the first place.
So basically my worries are:
• the alternative is not significantly better
• migration might take time with no clear benefits
• people might feel they are doing FP wrong
I think putting it in a separate module would make it clear that Option
is not recommended in the future and promote Nullable types. It will also enable people to migrate incrementally (or even not migrate, but coexist, writing new code with nullable types, keeping the old with Option).stojan
06/17/2020, 7:45 PMFred Friis
06/18/2020, 3:25 AMraulraja
06/19/2020, 7:43 AMraulraja
06/19/2020, 7:50 AMraulraja
06/19/2020, 7:51 AMraulraja
06/19/2020, 7:51 AMraulraja
06/19/2020, 7:54 AMraulraja
06/19/2020, 7:56 AMraulraja
06/19/2020, 8:06 AMraulraja
06/19/2020, 8:08 AMFred Friis
06/21/2020, 11:55 PM