HackerTrans
TopNewTrendsCommentsPastAskShowJobs

flaie

no profile record

comments

flaie
·9 ay önce·discuss
Good article.

Maybe you could look up the Try monad API (Scala or Vavr works in Java + Kotlin), by using some extra helper methods you can have something probably a little bit lighter to use.

I believe your example would look like the following with the Try monad (in Java):

  public UserDTO register(UserRegistrationRequest registrationRequest) {
    return Try.of(() -> authService.userExists(registrationRequest.email))
      .filter(Objects::isNull, () -> badRequest("user already exists"))
      .map(userId -> authService.register(registrationRequest.email, registrationRequest.password))
      .get();
  }
The login() function would be using the same pattern to call authService.verify() then filtering nonNull and signing the JWT, so it would be the same pattern for both.
flaie
·2 yıl önce·discuss
This is what I thought about OCaml when I first tried in 2001. I still do.
flaie
·2 yıl önce·discuss
Looks nice, I didn't knew about this tool. Sad to see 217 open PR, and nothing gets merged.
flaie
·2 yıl önce·discuss
Exactly this, bookmarked.
flaie
·3 yıl önce·discuss
This was a very good read, and I did learn some nice tricks, thank you very much.
flaie
·3 yıl önce·discuss
Thank you for sharing this was really nice and interesting.
flaie
·14 yıl önce·discuss
This is only because you're british and because of the way you learned how to measure things when you were young.

I'm totally unable to represent in my head how really tall "about five foot" is whereas 1,50m is totally understandable for me, easy to visualize.