thatassemblyguyJanitor of Technical Debt.Registered Userregular
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).
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
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.
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.
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.
0
thatassemblyguyJanitor of Technical Debt.Registered Userregular
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.
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.
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.
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.”
+1
thatassemblyguyJanitor of Technical Debt.Registered Userregular
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.
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
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.
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.
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.
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 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.
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
0
Ear3nd1lEärendil the Mariner, father of ElrondRegistered Userregular
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.
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.
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.
0
gavindelThe reason all your softwareis brokenRegistered Userregular
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.
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.
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.
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
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
?? 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.
?? 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.
@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?
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.
0
gavindelThe reason all your softwareis brokenRegistered Userregular
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."
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..."
Posts
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).
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
That's maybe what you meant anyways, but the nice thing is that then I can decide to hey maybe add some context.
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.
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.
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.”
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.
So if we updated this endpoint to return that data as well then what would be the point of it?
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
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.
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.
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.
Feels like the sort of thing that would make nix useful.
I always ask people to take them for a walk, but no one ever does. Poor little guys.
Early long weekend!
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.
What's so wrong with:
?? Simple, straightforward, you know what is happening.... Sigh.
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:
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
"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.
Check is not specific enough, comment is misleading
You're putting a lot of faith into javascript
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.
Same. Though I wish fewer of those answers started with "it's stupid, but..."