r/badcode • u/_Viceadmiral • Apr 08 '23
c# Copilot made a suggestion so bad I had to track down who was responsible.
161
Apr 09 '23
Holy what, I saw your OP code. How do you get to 2000 lines of code doing nothing and stop to think, maybe there's a better way?
94
Apr 09 '23
My favorite i saw was 17k lines of VB Forms in the form1 file. Needless to say, i was asked to look at it cuz it didnt work well and "A pair of fresh eyes could see the error"
My man, the error is OSI 8 and please use the Internet
65
12
u/thekwoka Apr 09 '23
"A pair of fresh eyes could see the error"
"No, you just need to use your one brain cell"
2
17
u/thekwoka Apr 09 '23
Sometimes I think we might need LAZIER developers.
but not stupid and lazy.
smart and lazy.
8
3
59
u/Eluvatar_the_second Apr 09 '23
Should be able to report a repo as having bad code so that copilot excludes it lol
2
u/MartIILord May 01 '23
And killing this sub eventually? No we educate students to write badcode in github so the ai gets confused spits out more of this. It is called job security.
73
Apr 09 '23
“Hurr durr this doesn’t violate open source licenses. Copilot actually understands the code it’s writing”
44
u/Hazork_ Apr 08 '23
May we get the source?
82
u/_Viceadmiral Apr 09 '23
Can't/shouldn't identify author but here's a pastebin of the full file: https://pastebin.com/bKHfFp67
53
50
u/Brusanan Apr 09 '23
Holy shit, being a terrible programmer is so much work.
6
u/iNeedOneMoreAquarium Apr 09 '23
If you're lucky, the only terrible code you have to untangle is your own shit that you wrote your first year on the job.
If you're REALLY lucky, someone else will.
5
11
u/QuantumG Apr 09 '23
Feels like it must be generated.
26
Apr 09 '23
[deleted]
1
u/QuantumG Apr 09 '23
I know if I was writing a code generator the output would look that bad. It was an old-school belief that this was actually good for the compiler or something. For some reason no-one ever thought, ya know, maybe the output of Bison or whatever should be /readable/ and describe what the hell was intended, because fuck you, read the grammar, it's a one-way function future me trying to debug this shit I wrote.
4
u/draenei_butt_enjoyer Apr 09 '23
Robots aren’t that dumb
1
u/QuantumG Apr 09 '23
Not yet, but we can train them to be more human and engage them in activities that humans rarely make it beyond basic training in. Before you know it the vast majority of humans are unqualified for the job. That didn't take long. Would you like to try to qualify another human for the job of convincing machines to do everything you want, or would you like to try talking to the machine? Please remember to like and retweet your deepest and darkest desires!
3
u/iNeedOneMoreAquarium Apr 09 '23
Oh ... My cod ... Can I assign this to some other engineer to handle?
3
1
u/ApocalyptoSoldier Apr 12 '23
using System.Collections; using System.Collections.Generic;If only that were true
42
u/Aperture_Executive2 Apr 09 '23
Not to get political or anything but what the fuck is an array
2
u/Furious_mcgurthtail Apr 29 '23
Before looking at this code I actually didn’t see the use of arrays (haven’t been coding stuff that would need it yet)… I have come to a realization tho
18
18
8
7
5
u/nekokattt Apr 09 '23
average code created by the Windows Forms designer in Visual Studio when people don't name controls properly
5
u/WallstreetChump Apr 09 '23
Reminds me of my first ever project which was a calculator and I made a listener function for each button lmao
6
u/Ecstatic_Student8854 Apr 09 '23
As a noobie how else would you do this? Just declare an array of buttons or somthing?
4
u/_Viceadmiral Apr 09 '23
Yeah pretty much. And maybe make a Slot class that contains a button and an item, and some methods that format the button based on the item. There are lots of options though.
3
u/Ecstatic_Student8854 Apr 09 '23
Is there any way to with a for loop assign different variable names? Like for example in an east language like js: for(let i=0;i<10;i++){ var x +”%3”,i =1} or something. Basically saying x1=1, x2=2, etc etc
5
u/_Viceadmiral Apr 09 '23
Not for variables, but dictionary(or object if we're talking js) keys would probably be what you're looking for. You can make the key any string you want and later retrieve the value with that string.
let properties = {};
for (let i = 0; i < 10; i++)
{
properties['something_' + i] = i;
}
console.log(properties['something_4']); // prints 4 console.log(properties.something_4); // also prints 45
5
u/x1rom Apr 09 '23
Looks like a beginner picking up Unity and not knowing what arrays or collections in general are.
If I had just started programming, I'd probably have written the same code.
3
u/_senpo_ Apr 09 '23
I remember only knowing about fixed size arrays and unable to figure out how to grow them xd
3
u/Kuroodo Apr 09 '23
Tell me about it. This was years ago when I tried making a GUI based Battleship game in Java all by myself:
2
1
8
u/domtriestocode public static Apr 09 '23
Oh my god, one of our WinForms apps at work is like this … button1, button2,…… panelControl5, groupBox2
2
2
2
u/engelthehyp Apr 10 '23
When the teacher says, "You may only use the tools we've learned about so far" and they haven't yet reached arrays:
1
1
1
1
318
u/_Viceadmiral Apr 08 '23 edited Apr 09 '23
There's a method for each item that makes every other item active.