this post was submitted on 15 Nov 2024
52 points (94.8% liked)

Programming Horror

1923 readers
1 users here now

Welcome to Programming Horror!

This is a place to share strange or terrible code you come across.

For more general memes about programming there's also Programmer Humor.

Looking for mods. If youre interested in moderating the community feel free to dm @[email protected]

Rules

Credits

founded 2 years ago
MODERATORS
 
top 15 comments
sorted by: hot top controversial new old
[โ€“] python 18 points 2 months ago (1 children)

smh, could have used the short form ()=>{ instead of function ๐Ÿ˜ค

[โ€“] Deebster 11 points 2 months ago

I've been coding long enough that I still think of that as a fairly new thing in JS.

[โ€“] Kissaki 11 points 2 months ago

In German we say "doppelt hรคlt besser". Is there an English saying like that? "Twice is stronger/more stable/holds better."

[โ€“] [email protected] 11 points 2 months ago (1 children)
[โ€“] PoolloverNathan 7 points 2 months ago (1 children)

Someone's handed me nested base-64 encoded JSON before and to this day I am moderately annoyed at them.

[โ€“] [email protected] 2 points 2 months ago (1 children)

unity kinda does this ! there is a json file wirh a base-64 encoded string (UTF-16 encoding) and is a completely different data structure with embedded json

[โ€“] PoolloverNathan 2 points 2 months ago

I just had to add URL-encoded TOML to something due to a certain Rust crate's constraints.

[โ€“] zygo_histo_morpheus 11 points 2 months ago

Why settle on cammel case ("saveGame") or upper cammel case ("SaveGame") when you can have one of each?

[โ€“] [email protected] 10 points 2 months ago (1 children)

I WILL NOT USE ANOTHER LINE. I DON'T NEED IT

[โ€“] [email protected] 5 points 2 months ago (2 children)

The best code has the fewest lines.

[โ€“] logging_strict 1 points 1 month ago (1 children)

... an adult enters the conversation ;-)

Easier maintainability is everything

The best code

Comes with tests what are easy to understand. As bugs are discovered, should be written in such a way, that it's very easy to add more test cases.

Fewest lines is not necessarily easy to maintain.

[โ€“] [email protected] 1 points 1 month ago* (last edited 1 month ago) (1 children)

Lol, I should have been marking that with a satire tag

[โ€“] logging_strict 1 points 1 month ago (1 children)

Whether you did or not, non-obvious what the answer would be.

Might get 1000 cringe worthy responses that can't withstand scrutiny

So my eyes need not bleed and my mind not splatter across the room, wrote a worthy response.

[โ€“] [email protected] 1 points 1 week ago* (last edited 1 week ago)

This is just as easy to write, just as sloppy but hopefully way easier to read.

Game.onload = (data)=>{
let a = data;
a = JSON.decode(a)["saveGame"][0];
a = JSON.decode(a)["SaveGame"];
return a;
}