86
Self-documenting Code (lackofimagination.org)
you are viewing a single comment's thread
view the rest of the comments
[-] dohpaz42@lemmy.world 2 points 1 month ago

That’s fair. How would you go about implementing the service? I always love seeing other people’s perspectives. 😊

[-] olafurp@lemmy.world 1 points 1 month ago

More or less the same but the user gets passed as a method parameter each time. Validators would be in my opinion a long function inside the service also with named variables like this because it's just easy to read and there are no surprises. I'd probably refactor it at around 5 conditions or 30 lines of validation logic.

I recommend trying out using the constructor in services for tools such as a database and methods for data such as user. It will be very easy to use everywhere and for many users and whatever

const passwordIsValid = ...
if (!passwordIsValid){
  return whatever
}
this post was submitted on 21 Oct 2024
86 points (86.4% liked)

Programming

17314 readers
130 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 2 years ago
MODERATORS