• 0 Posts
  • 2 Comments
Joined 1 year ago
cake
Cake day: June 23rd, 2023

help-circle

  • Ew no.

    Abusing language features like this (boolean expression short circuit) just makes it harder for other people to come and maintain your code.

    The function does have opportunity for improvement by checking one thing at a time. This flattens the ifs and changes them into proper sentry clauses. It also opens the door to encapsulating their logic and refactoring this function into a proper validator that can return all the reasons a user is invalid.

    Good code is not “elegant” code. It’s code that is simple and unsurprising and can be easily understood by a hungover fresh graduate new hire.