As was foretold, we've added advertisements to the forums! If you have questions, or if you encounter any bugs, please visit this thread: https://forums.penny-arcade.com/discussion/240191/forum-advertisement-faq-and-reports-thread/

[Programming] Initial commit

2456714

Posts

  • thatassemblyguythatassemblyguy Janitor of Technical Debt .Registered User regular
    Probably only useful for debugging the API, "I sent {id}=555, and received what the internal API logic thinks is customerId: 555"

    Otherwise, I'd be inclined to agree with you that it doesn't need to be cluttering the return array for something that is supposed to be a 1-1 or 1-* (depending on how many unique reward programs this API tracks).

  • JasconiusJasconius sword criminal mad onlineRegistered User regular
    urahonky wrote: »
    Question:

    When writing a rest API... If I have something like this:

    /customer/{id}/rewards

    When you get the rewards data (in an array) does it make sense to include the customer id in there as well?
    {
    [
        rewardId: 1,
        amount: 10,
        customerId: 555
    ]
    }
    

    To me the id doesn't fit because it's a rewards data element and not customer.

    make sense... i guess it depends on what you do with it

    in my own APIs, I tend to include the ID because it costs nothing for the server to render and it gives me more option on the client side to handle the data if I've got the relevant ID right in my pocket as I parse the response

  • urahonkyurahonky Registered User regular
    I guess my OCD brain just can't handle it lol. You already have the customer ID. You don't need it placed in each element of a reward return array. Ah well. I was outvoted on my team anyway so it's going. It just bothers me more than it should lol.

  • InfidelInfidel Heretic Registered User regular
    Also that should just be an array if that's actually the intended output, although often I find our designs not returning that raw because error/additional info always creeps back in and then it's a pain to change later.
    {
      rewards: [
        {id: 1, amount: 10},
        ...
      ]
    }
    

    That's maybe what you meant anyways, but the nice thing is that then I can decide to hey maybe add some context.
    {
      customer: {id: 555, name: ...},
      rewards: [
        {id: 1, amount: 10},
        ...
      ]
    }
    

    Use it, or not, but I tend to structure my responses to be multi-model / nested models because anytime I don't I hate myself later.

    OrokosPA.png
    thatassemblyguy
  • InfidelInfidel Heretic Registered User regular
    Easy for someone to ignore the customer node if they don't need it, if you have an ID but not the name handy for whatever reason oh hey now you don't need to make another call? Depending on your endpoints and views this is convenient and something you might find yourself doing and again, hate yourself later when it becomes necessary.

    OrokosPA.png
  • thatassemblyguythatassemblyguy Janitor of Technical Debt .Registered User regular
    Infidel wrote: »
    Easy for someone to ignore the customer node if they don't need it, if you have an ID but not the name handy for whatever reason oh hey now you don't need to make another call? Depending on your endpoints and views this is convenient and something you might find yourself doing and again, hate yourself later when it becomes necessary.

    In most applications where we're talking about customer IDs, I would consider this a bug. The ID is only useful (in this very specific example bolded) to look-up in a table of customer names, right? I wouldn't want my caller to be able to grab the entire table of customer names (or range in) and store locally. This seems like a good way to leak information.

  • urahonkyurahonky Registered User regular
    Well we have two endpoints. One with the id and the other with an email as a query param. So either way you have the customer information you need before calling rewards.

  • InfidelInfidel Heretic Registered User regular
    Infidel wrote: »
    Easy for someone to ignore the customer node if they don't need it, if you have an ID but not the name handy for whatever reason oh hey now you don't need to make another call? Depending on your endpoints and views this is convenient and something you might find yourself doing and again, hate yourself later when it becomes necessary.

    In most applications where we're talking about customer IDs, I would consider this a bug. The ID is only useful (in this very specific example bolded) to look-up in a table of customer names, right? I wouldn't want my caller to be able to grab the entire table of customer names (or range in) and store locally. This seems like a good way to leak information.

    Depends what information is useful AND allowed but the point is that you can fit stuff in without breaking your existing response schema or making it inconsistently shitty. Think of it like how useful having a sometimes present but consistently formatted “errors” top level node can be. That’s the same principle.

    OrokosPA.png
    thatassemblyguy
  • InfidelInfidel Heretic Registered User regular
    Like another way to look at this (because don’t get hung up on making sense of partial / dumbed down examples):

    You considered putting the customer ID in every reward object when responding with a single customers rewards (as indicated by the route rule).

    Whether you did or didn’t the fact that you considered it there means your schema stinks. You should already have a principle in place that neatly answers “if I wanted this in the response I know where to put it.”

    OrokosPA.png
    thatassemblyguy
  • thatassemblyguythatassemblyguy Janitor of Technical Debt .Registered User regular
    Infidel wrote: »
    Infidel wrote: »
    Easy for someone to ignore the customer node if they don't need it, if you have an ID but not the name handy for whatever reason oh hey now you don't need to make another call? Depending on your endpoints and views this is convenient and something you might find yourself doing and again, hate yourself later when it becomes necessary.

    In most applications where we're talking about customer IDs, I would consider this a bug. The ID is only useful (in this very specific example bolded) to look-up in a table of customer names, right? I wouldn't want my caller to be able to grab the entire table of customer names (or range in) and store locally. This seems like a good way to leak information.

    Depends what information is useful AND allowed but the point is that you can fit stuff in without breaking your existing response schema or making it inconsistently shitty. Think of it like how useful having a sometimes present but consistently formatted “errors” top level node can be. That’s the same principle.

    Oh yeah. I was only picking at the example nit in bold for funsies.

    Everything else about the response schema update in the previous post is very well received. What you proposed is experienced, good, flexible design and very helpful for foundational API functions.

  • urahonkyurahonky Registered User regular
    edited March 29
    Ironically our GetCustomer endpoint returns a customer with all of their rewards as well lol.

    So if we updated this endpoint to return that data as well then what would be the point of it?

    urahonky on
  • urahonkyurahonky Registered User regular
    https://voicebot.ai/2023/02/02/new-microsoft-teams-premium-uses-chatgpt-to-take-meeting-notes/

    Also a heads up for those who use Teams a lot. This happened to us yesterday and it was like "Note Taking Bot" as the name that came into the meeting. Had no idea who or what it was. We figured it was someone else but as soon as they joined and had no idea what it was then we booted it lol

    durandal4532thatassemblyguyBullheadZilla360
  • durandal4532durandal4532 Registered User regular
    I have a professional development stipend that’s actually pretty generous at my workplace, are there any like training or coursework places that people think are really worth the money? I had a good time doing some specifically AWS coursework a while back using Pluralsight so I may rebuy that but I was wondering if there were other places people preferred.

    Take a moment to donate what you can to Critical Resistance and Black Lives Matter.
  • urahonkyurahonky Registered User regular
    Ugh waiting on 2+ approvals on a PR when I'm debugging an issue that is blocking UAT testing is frustrating as hell.

  • Ear3nd1lEar3nd1l Eärendil the Mariner, father of Elrond Registered User regular
    urahonky wrote: »
    Ugh waiting on 2+ approvals on a PR when I'm debugging an issue that is blocking UAT testing is frustrating as hell.

    My favorite experience about situations like that is when getting said PR approved takes weeks for someone from on high to decide to look at it, no matter how much you pester them about it.

    urahonky
  • urahonkyurahonky Registered User regular
    Ear3nd1l wrote: »
    urahonky wrote: »
    Ugh waiting on 2+ approvals on a PR when I'm debugging an issue that is blocking UAT testing is frustrating as hell.

    My favorite experience about situations like that is when getting said PR approved takes weeks for someone from on high to decide to look at it, no matter how much you pester them about it.

    Yeah I may have added myself as an admin on my other repo so I didn't have to wait unless I wanted to. Today half our team is on PTO so I'm pestering people in Slack every few minutes trying to troubleshoot.

  • ZekZek Registered User regular
    I think my worst fears are coming true: I'm rapidly approaching the point in my career where I barely have time for coding anymore. Reviewing code and docs, answering chat/emails, meetings, sprint planning - then before I know it my day's over. I still feel weird just coming up with work and telling a junior dev to do it.

    It's awkward because I want to code more, but I'd have to take a job I'm overqualified for and just coast, which I think would be unfulfilling. I think I'm just going to have to adapt. Maybe it's good timing anyway since I'm probably safe from the AI.

  • urahonkyurahonky Registered User regular
    Zek wrote: »
    I think my worst fears are coming true: I'm rapidly approaching the point in my career where I barely have time for coding anymore. Reviewing code and docs, answering chat/emails, meetings, sprint planning - then before I know it my day's over. I still feel weird just coming up with work and telling a junior dev to do it.

    It's awkward because I want to code more, but I'd have to take a job I'm overqualified for and just coast, which I think would be unfulfilling. I think I'm just going to have to adapt. Maybe it's good timing anyway since I'm probably safe from the AI.

    I feel ya dude. I don't want to get to this point yet... but my job is definitely pushing me towards it.

  • TelMarineTelMarine Registered User regular
    Zek wrote: »
    I think my worst fears are coming true: I'm rapidly approaching the point in my career where I barely have time for coding anymore. Reviewing code and docs, answering chat/emails, meetings, sprint planning - then before I know it my day's over. I still feel weird just coming up with work and telling a junior dev to do it.

    It's awkward because I want to code more, but I'd have to take a job I'm overqualified for and just coast, which I think would be unfulfilling. I think I'm just going to have to adapt. Maybe it's good timing anyway since I'm probably safe from the AI.

    I think this usually happens if you're one of the only "senior level" people on a team. Companies will always take advantage. Not sure about how many years of work experience you have, but that's been what I've noticed (I'm on year 13). At this extremely small company I'm at, there's no one else filling a lot of those roles for this team so I'm writing and detailing my own and other tickets, epics, and some planning. I'm also the only one doing comprehensive code review which can take a while. Thankfully, I am still able to do a majority coding otherwise I'd just leave, since coding is what I'm best at and most useful for. I had a friend at a company I worked for that kept running into this conundrum as well before joining a big tech company where he was finally able to get back to coding.

    If we assume that retirement age is 65 let's say (rising to nearly 70 now in the US), and we assume we start working in our mid 20s, it's really ridiculous that 10+ years into a career, which is still the beginning, this kind of stuff happens or that people are "senior level" (whatever that means, as it varies across companies). So if your job has gotten like that, maybe it's time for you to find a different company.

    3ds: 4983-4935-4575
  • Ear3nd1lEar3nd1l Eärendil the Mariner, father of Elrond Registered User regular
    I like being a consultant/contractor for this very reason. I've been doing this since 1995 and if I had to work for a company as a regular employee, I would never write a single line of code and spend all day in meetings. I'd rather shove a fork in my eye.

  • ZekZek Registered User regular
    TelMarine wrote: »
    Zek wrote: »
    I think my worst fears are coming true: I'm rapidly approaching the point in my career where I barely have time for coding anymore. Reviewing code and docs, answering chat/emails, meetings, sprint planning - then before I know it my day's over. I still feel weird just coming up with work and telling a junior dev to do it.

    It's awkward because I want to code more, but I'd have to take a job I'm overqualified for and just coast, which I think would be unfulfilling. I think I'm just going to have to adapt. Maybe it's good timing anyway since I'm probably safe from the AI.

    I think this usually happens if you're one of the only "senior level" people on a team. Companies will always take advantage. Not sure about how many years of work experience you have, but that's been what I've noticed (I'm on year 13). At this extremely small company I'm at, there's no one else filling a lot of those roles for this team so I'm writing and detailing my own and other tickets, epics, and some planning. I'm also the only one doing comprehensive code review which can take a while. Thankfully, I am still able to do a majority coding otherwise I'd just leave, since coding is what I'm best at and most useful for. I had a friend at a company I worked for that kept running into this conundrum as well before joining a big tech company where he was finally able to get back to coding.

    If we assume that retirement age is 65 let's say (rising to nearly 70 now in the US), and we assume we start working in our mid 20s, it's really ridiculous that 10+ years into a career, which is still the beginning, this kind of stuff happens or that people are "senior level" (whatever that means, as it varies across companies). So if your job has gotten like that, maybe it's time for you to find a different company.

    Yep I'm one of two senior devs on my team - 15 years experience - and most of the team is considerably more junior. If I stopped doing my TL work, it simply wouldn't get done. And it wouldn't really be fair to the team because I was brought on for my seniority, they would have chosen somebody else if they knew I'd refuse to do TL work.

    This was a brand new project a year ago so I got to write a ton of green field code which was great. But successful projects grow quickly, with more projects and more sibling teams involved, so there's no way around the increase in organizational tasks.

  • electricitylikesmeelectricitylikesme Registered User regular
    I wonder if you could have an immutable docker container registry where it didn't actually store the underlying images at all, but on image pull would do a build from scratch and push it into cache?

    Feels like the sort of thing that would make nix useful.

  • gavindelgavindel The reason all your software is brokenRegistered User regular
    The best part of going on vacation is that all your work items are right there waiting on you when you get back! Such faithful pups.

    Book - Royal road - Free! Seraphim === TTRPG - Wuxia - Free! Seln Alora
    Ear3nd1lurahonky
  • Ear3nd1lEar3nd1l Eärendil the Mariner, father of Elrond Registered User regular
    gavindel wrote: »
    The best part of going on vacation is that all your work items are right there waiting on you when you get back! Such faithful pups.

    I always ask people to take them for a walk, but no one ever does. Poor little guys.

    gavindelurahonky
  • admanbadmanb unionize your workplace Seattle, WARegistered User regular
    I've usually forgotten everything by the time I get back, so it's kind of like they're brand-new.

    Orcagavindelurahonky
  • urahonkyurahonky Registered User regular
    Ugh man. Jr Dev I was chatting about before has completely hosed our UAT environment and unfortunately his fiber optic line is down at the moment so he's dead in the water... and now our testers can't do anything.

  • InfidelInfidel Heretic Registered User regular
    urahonky wrote: »
    Ugh man. Jr Dev I was chatting about before has completely hosed our UAT environment and unfortunately his fiber optic line is down at the moment so he's dead in the water... and now our testers can't do anything.

    Early long weekend!

    OrokosPA.png
    gavindelCarpy
  • JasconiusJasconius sword criminal mad onlineRegistered User regular
    if anyone is a regular pycharm user one of their most recent updates has a new UI beta and its delightful.. highly recommend upgrading. borrows a lot of the better aspects of VS Code

    Elaro
  • urahonkyurahonky Registered User regular
    function ciEquals(a, b) {
        return typeof a === 'string' && typeof b === 'string'
            ? a.localeCompare(b, undefined, { sensitivity: 'accent' }) === 0
            : a === b;
    }
    

    I hate this shit so much. Especially since we're looking for the word "ERROR" and so we've decided to yoink this from SO and adopt it in our project.

  • dporowskidporowski Registered User regular
    urahonky wrote: »
    function ciEquals(a, b) {
        return typeof a === 'string' && typeof b === 'string'
            ? a.localeCompare(b, undefined, { sensitivity: 'accent' }) === 0
            : a === b;
    }
    

    I hate this shit so much. Especially since we're looking for the word "ERROR" and so we've decided to yoink this from SO and adopt it in our project.

    You're gonna need a young priest and an old priest.

    That is fucked up, right there.

  • urahonkyurahonky Registered User regular
    *don's old man hat*

    What's so wrong with:
    if(string.toLowerCase() === 'error')
    

    ?? Simple, straightforward, you know what is happening.... Sigh.

  • PhyphorPhyphor Building Planet Busters Tasting FruitRegistered User regular
    Okay I just found the best abuse of the C++ standard I've seen in a long damn time

    You can use structured binding to pick apart a structure and you can use constexpr if to pick a value. Combine with a bit of template magic to mostly figure out the number of elements in a struct and you can do this:
    struct s {
      int a;
      std::string b;
    };
    
    template<size_t> struct decompose;
    
    template<> struct decompose<2>
    {
      template<size_t I, typename T>
      constexpr static auto get(T& o) {
        auto& [_1, _2] = o;
        if constexpr(I == 0) return _1;
        else if constexpr(I == 1) return _2;
      }
    };
    
    s _s = {1, "2"};
    static_assert(std::is_same_v<int, decltype(decompose<2>::get<0>(_s))>);
    static_assert(std::is_same_v<std::string, decltype(decompose<2>::get<1>(_s))>);
    assert((decompose<2>::get<0>(_s) == 1));
    assert((decompose<2>::get<1>(_s) == "2"));
    

    You just have to write one specialization for every number in the sequence [1, N] up to the largest struct you need. Then you can iterate over a struct's members (recursively!) and do whatever with them. IDL-free codegen-free type-safe serialization! The library I found has really shit compile times, but I think that's because everything is horrible SFINAE everywhere and the decomposition is a giant 4000 line single function, hopefully my partial struct specialization version is much faster

    Barrakketh
  • dporowskidporowski Registered User regular
    urahonky wrote: »
    *don's old man hat*

    What's so wrong with:
    if(string.toLowerCase() === 'error')
    

    ?? Simple, straightforward, you know what is happening.... Sigh.

    "OMG WHAT IF IT ISN'T A STRING?!?!"

    Which, I mean, if you're getting not-string out of your CI logging, you have some other fuckin' problems. Yeah, sure, "type safety" but if you know your inputs are restricted... My APIs aren't gonna start serving me cat jpegs unexpectedly, I don't need to make sure I'm not getting images back.

    urahonkyLD50
  • EchoEcho ski-bap ba-dapModerator mod
    Every now and then I remember the code in Docker for generating random container names.

    xca0giyuwb93.png

    admanbFiskebentamnesiasofthlprmnkyZilla360
  • TelMarineTelMarine Registered User regular
    Echo wrote: »
    Every now and then I remember the code in Docker for generating random container names.

    xca0giyuwb93.png

    Check is not specific enough, comment is misleading

    3ds: 4983-4935-4575
  • TelMarineTelMarine Registered User regular
    dporowski wrote: »
    urahonky wrote: »
    *don's old man hat*

    What's so wrong with:
    if(string.toLowerCase() === 'error')
    

    ?? Simple, straightforward, you know what is happening.... Sigh.

    "OMG WHAT IF IT ISN'T A STRING?!?!"

    Which, I mean, if you're getting not-string out of your CI logging, you have some other fuckin' problems. Yeah, sure, "type safety" but if you know your inputs are restricted... My APIs aren't gonna start serving me cat jpegs unexpectedly, I don't need to make sure I'm not getting images back.

    You're putting a lot of faith into javascript

    3ds: 4983-4935-4575
    electricitylikesme
  • TelMarineTelMarine Registered User regular
    edited April 12
    @Echo , you're the resident Go person, how do you set up your test files? In a separate package called "tests" or equivalent or adjacent to the source files?

    TelMarine on
    3ds: 4983-4935-4575
  • EchoEcho ski-bap ba-dapModerator mod
    TelMarine wrote: »
    Echo, you're the resident Go person, how do you set up your test files? In a separate package called "tests" or equivalent or adjacent to the source files?

    Both! Test packages are the one exception to "one package per directory", so if I have the package foo, test files are adjacent to the files they're testing, ie if I have foo/handler.go, I'll also have handler_test.go belonging to the package foo_test.

    This means that foo_test can only test exported stuff from the foo package, so on occasion there are exceptions where I want to test unexported stuff, but that's not super-common. I haven't checked in detail, but I think the compiler is smart enough to not actually include test stuff from package foo when compiling since nothing ought to be referencing the tests.

  • gavindelgavindel The reason all your software is brokenRegistered User regular
    Been working as a programmer for going on 8 years now. A lot of questions just don't have easy answers. Still, it's nice when someone comes to you for help and you can be like, "oh, sure, I know how to solve that."

    Book - Royal road - Free! Seraphim === TTRPG - Wuxia - Free! Seln Alora
  • admanbadmanb unionize your workplace Seattle, WARegistered User regular
    gavindel wrote: »
    Been working as a programmer for going on 8 years now. A lot of questions just don't have easy answers. Still, it's nice when someone comes to you for help and you can be like, "oh, sure, I know how to solve that."

    Same. Though I wish fewer of those answers started with "it's stupid, but..."

    KhepragavindelEchoDisruptedCapitalisturahonkyZilla360
Sign In or Register to comment.