• 7 Posts
  • 132 Comments
Joined 1 year ago
cake
Cake day: September 21st, 2024

help-circle



  • Just yesterday my library required a new password. The password requirements were:

    • 8 to 18 characters
    • uppercase
    • lowercase
    • number
    • one of the 8 special characters listed

    When borrowing from the library physically, I need to enter this password on a touchscreen keypad. So no copy and paste from a password manager.

    They used to have birthdates as the assigned password for everyone. If you request a password reset, it resets to the birthdate. You have to change it on first login.

    A little better than before, but doesn’t feel secure.

    On the other hand, abuse is kinda difficult.

    For physically loaning books, you need the library card with its RFID chip. For anything digital, there’s no incentive or possibility for abuse really.


















  • Depending on the language exceptions are used in many different ways. Some use it liberally for all kinds of error handling.

    A good feature of Exceptions is you can throw them all the way up the stack and handle them there, giving you loose coupling between the code that calls the dangerous code and the one that catches it.

    Exceptions have a big runtime overhead, so using them for normal control flow and error handling can be a bit meh.

    Using return types can be great, if the language has good support for. For example swift enums are nice for this.

    enum ResultError  {
      case noAnswer;
      case couldNotAsk;
      case timeOut
    }
    
    enum Result {
      case answer: String;
      case error: ResultError
    }
    
    func ask(){
      let myResult = askQuestion(“Are return types useful?”);
      switch myResult {
        case answer: 
          print(answer);
        case error:
           handleError(error);
      }
    }
    
    func handleError(error: ResultError) {
      switch ResultError {
        case noAnswer:
          print(“Received no answer”);
        case couldNot:
          …
      }
    
    }
    

    Using enums and switch means the compiler ensures you handle all errors in a place you expect.