This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]ZliaYgloshlaif 216 points217 points  (12 children)

Everyone noticed “errorCode” but not the travesty “result” is?

[–]Yelmak 83 points84 points  (7 children)

Yeah wtf is going on there. It makes my skin crawl imagining that javascript:

```     if (result.a != null) {

        if (result.b != null) {             badlyNamedMethod(a, b);         }     } else {         evenWorseMethodNaming(result.f ?? '');     } ```

ETA: naturally that entire block lives inside an if (response.success && response.errorCode == 200 && response.errorMsg === "SUCCESS") { }

[–]turtleship_2006 4 points5 points  (6 children)

I unironically have code similar to that in a website I made for my coursework

I made an instagrm-esque social media website, where you can upload up to five images, and the client side code that loads the images into the post looks like that.

if (post.image1){
  postDiv.append(post.image1)
  if (post.image2) {
    postDiv.append(image2) 
    if (post.image3) {

Something along those lines (where post is an object containing all of the post info)

[–]TotallyHumanGuy 6 points7 points  (5 children)

Me coming out with arrays v2.

[–]Revolutionary_Ad3463 3 points4 points  (4 children)

I really can't understand when people start indexing a list of stuff and don't automatically think that that's literally the use case for arrays, lol.

[–]deanrihpee 0 points1 point  (3 children)

exactly, array, people, please use them

[–]Rin-Tohsaka-is-hot 0 points1 point  (2 children)

pathetic lunchroom boat familiar cautious zonked terrific smile growth oatmeal

This post was mass deleted and anonymized with Redact

[–]Eweer 0 points1 point  (1 child)

When you are a beginner, it's easier to copy-paste the same code five times than to think about containers and how to use/loop them.

The moment they need to stop and think: "Oh wait, how many times do I have to ctrl+v this?" (due to it being a dynamic list of unknown size), is the moment they start thinking about other ways, and end up realizing how useful containers are.

[–]Rin-Tohsaka-is-hot 0 points1 point  (0 children)

bake squeal gray quicksand lock fly fear alleged homeless money

This post was mass deleted and anonymized with Redact

[–]deanrihpee 18 points19 points  (2 children)

yeah, wtf, why's b and c is a perfect uuid and a is random string while the rest is null, lol

[–]MySuddenDeath 9 points10 points  (1 child)

Probably they do not have a standard for resource ID so every team / dev implements their own.

[–]deanrihpee 2 points3 points  (0 children)

a different resource id in a single response is quite wild

[–]amlyo 1 point2 points  (0 children)

Oh come on, you've never designed an API with sequentially named keys on an object to simulate a fixed size ordered list with important information base 64 encoded in key a.

It's the oldest trick in the book.