Skip to content

Conversation

@nkcoder
Copy link
Owner

@nkcoder nkcoder commented Dec 3, 2025

What

  1. Optional Return Types: Optional communicates that absence is expected; orThrow methods
    for when null is a bug
  2. Method References: userMapper::toResponseOrThrow is cleaner than user ->
    userMapper.toResponseOrThrow(user)
  3. Functional Chains: repository.findById(id).map(...).orElseThrow(...) is more readable than
    nested if-else
  4. Constants Classes: Centralize messages for consistency, easier i18n, and preventing typos
  5. Compact Constructors: Normalize data (lowercase email, trim strings) at construction time
  6. Static Imports: import static ...ValidationMessages.* keeps code readable with constants

@nkcoder nkcoder merged commit c5830a4 into main Dec 3, 2025
2 checks passed
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

Successfully merging this pull request may close these issues.

2 participants