• 0 Posts
  • 79 Comments
Joined 1 year ago
cake
Cake day: June 17th, 2023

help-circle


  • What’s the purpose of foo? Why an ambiguous single character variable? What if the property was there but the value was null? Why not use (assuming JS) optional chaining?

    I’d approach it more like this:

    function getWhatevrProp(userData) (
      const default = { whatevr: "n/a" };
    
      return { ...default, ...userData }.whatevr;
    }
    

    Sorry, read too fast the first time. It’s more likely Python. I also don’t know Python well enough to give recommendations on that.


















  • Got hands on experience with this. Wasn’t my design choice but I inherited an app with a database where one of the keys was tied to a completely separate database. I mean at the time it probably made sense but the most unlikely of scenarios actually happened: that other database, the one I had zero control over, was migrated to a new platform. All of those keys were synthetic so of course they were like, “Meh, why we gotta keep the old keys?” So post-migration my app becomes basically useless and I spent 6 hours writing migration code, some of it on off hours, to fix my data.

    So it’s questionable whether a foreign key of a completely different system is a natural key, but at the very least never use a key YOU don’t control.