Bad code examples

i second this

I third this
threads die for a reason

Soā€¦ When will you be joining the programming team?

This was an offtopic post that didnā€™t add to the conversation. Whereas @DPHkraken showed how to properly post in the right thread when new things to discuss materialize.

2 Likes

I just had to do some really nasty code to get visual studio (thanks, microsoft) to compile Leviathan.

Previous version (that GCC, a good compiler, compiles without issues):

auto guard = (Leviathan::Locker::Object(this));

New version (it has a bit different approach because the previous approach just didnā€™t work with vs), this is also a good example how complex C++ template magic can get:

Leviathan::LockTypeResolver<std::remove_reference_t<decltype(
     Leviathan::Locker::AcessLock(this))>>::LType
     guard(Leviathan::Locker::AcessLock(this));

Might as well contribute

Bad coding example: all of YandereSim

Iā€™ve heard many people say that the dev is incompetent and thus the code is probably terrible (and part of the reason why it is taking so long). But has anyone actually seen the code in order to determine if it is actually terrible?

Philosophical question: does bad code exist if there is no one to see it?

depends on how well the game runs. And if it runs well, does it matter?

Multiple people have said that they or a friend of theirs has looked at the code before.

Also, the game is prone to have many bugs and gigantic framerate drops, even though the game isnt that graphically demanding.

More bad code: I donā€™t know how to turn a string into a number, so instead I have to turn the string into a color and take the red value. What in the even.
string.ToColor(args[1].." 0 0 0" ).r +1

Here is an example what happens when you write bad code:

2 Likes

Must be some brutal code to put him through so much agony.

1 Like

Iā€™m shamelessly reviving this thread to show my abomination of a loop:
Iā€™m currently learning machine language and basic assembly to code an arduino. However, in arduinoā€™s timers donā€™t exist, and each calculation takes the same amount of time. Because of this, I had to create this abomination to stall the thing:

;from  here

ldi r17,$ff 		; 
ldi r18,$00		; 
notequal1:
dec r17			; 

ldi r19,$ff	; load big number
ldi r18,$00	; load zero
	notequal3:
dec r19		; decrease the big number
cp r19,r18	; check if the big number equals zero
	breq equal3 	; if the big number equals zero, go to equal3
	rjmp notequal3 	; if the number does not equal zero, go to notequal3 (go back and decrease again)
	equal3:

cp r17,r18 		
breq equal1
rjmp notequal1
equal1:
;to here: there are 2 loops, of which one is inside the other. With the middle loop, r19 is out to 255. afterwards, it 		gets decremented by 0. After each decrement, it checks if r19 = 0. If it isn't, go back to decrementing.
; If it is, go to the next line, ending the loop. The outer loop is the same, but after each decrement the middle loop is repeated. This means that the inner loop is repeated 255^2 times total, or 65025 times.

Itā€™s a loop. Inside another loop.
Somebody end me

1 Like

Nearly a year necro, nice! I had a little arduino activity, though we had the code in a book, so I really donā€™t understand how the code works in arduino. Iā€™m sure someone on this forum will help you.

Anyway, maybe there is something in this website, who knows.

https://www.tutorialspoint.com/arduino/index.htm

It works. Itā€™s just really ugly. (Though apparently it is what youā€™re supposed to do, so assembly is just an ugly language in general)

This is not a programming help thread, this is for showcasing bad code.

1 Like

Another game that had its source code released (vvvvvvv) has really bad code:


Donā€™t do that
(also see that nice new discourse github embed)

1 Like

Holy shit thatā€™s bad. I like how even after that massive fucking switch case, he still proceeds to make if-else chains that are over 10 layers deep.

Terraria doesnā€™t have its code released, but it was decompiled. Every item (of the thousands) was part of an if-else chain.
It doesnā€™t help that so many items share functionalities.

Someone reviewed the decompiled Yandere Simulator source code for two and a half hours.

All of that in a single script? Damn.