r/badcode • • Jan 23 '20

c# Junior dev on first week delivered this

https://gist.github.com/fjod/2f5bca02fd9e3ca5acad7beadc8c6b73
11 Upvotes

24 comments sorted by

59

u/Kortike Jan 23 '20

Sooo are you going to go over it with them or just post it on Reddit for karma?

6

u/10199 Jan 24 '20

First: I fixed and cleared all his code, it's working but needed some maintaining. Yesterday he updated it (we still use svn on this project), also asked "how many things you had to fix". Today we will have a little chat about naming, deleting unused code, and this array thing; I hope he looked through my changes. His code gets job done, thats good for start.

Second: this sub is called "badcode" and I posted quality badcode here. What's wrong?

12

u/Fearmin Jan 25 '20

"I fixed his code I hope he looked at what I did to fix it" God the amount of entitlement coming from you... I would not like to work with you.

2

u/10199 Jan 25 '20

If it matters so much to you for some reason, he did not look at what I changed at all, until I explained all of this things. He tries to finish task as fast as possible, totally neglecting quality of code, which is understandable. I assured him not to hurry that much and spend some time cleaning up and looking through the code he is about to upload into version control.

9

u/PrutsendePrutser Jan 27 '20

From personal experience I'd recommend sitting down with him, giving feedback on his code, explaining why you would write the code in a different way. When I started my first development job I felt pressured to deliver as soon as possible (not because of external pressure, just being nervous). One of the senior developers actively giving me feedback and explanation, then letting me improve my own code based on that feedback, really helped to kick off my career.

If that same developer would improve my code, I'd suspect that there would not be enough time for me to actually try and find out what was changed, because clearly they let someone more experienced fix my mistakes. Sitting down with him and then letting him process the feedback you give will probably really help with his confidence, and will probably improve the quality of his work a lot.

2

u/10199 Jan 29 '20

I did exactly that, sit next to him, opened source control and explained what I changed and why

4

u/PrutsendePrutser Jan 30 '20

The next step would be to pass the feedback on to him, and let him make the changes, and then review those, though I can understand that might be a bit hard to create enough time for, depending on overall time pressure. But yeah, that sort of advice is really valuable, especially for someone who is starting out.

1

u/[deleted] Feb 05 '20

He tries to finish task as fast as possible, totally neglecting quality of code, which is understandable.

That's not understandable. Someone will have to maintain his code at some point.

3

u/Kortike Jan 24 '20

Nothing is wrong. A lot of the bad code posted here seems to be legacy stuff or things people find from their early days and not what a Junior Dev coworker wrote. So I was just making a comment because I hope that more experienced programmers are willing to take that extra step to teach and correct. Thanks for being a good one

1

u/Hobbit_Swag Mar 08 '20

I know this was almost 2 months ago but the internet is eternal. I’m with ya man, this sub is bad code and you posted just that lmao. Too many people outside their safe space in here.

37

u/TouchyUnclePhil Jan 23 '20

learning programming is hard and at least in my case its nothing short of a miracle im employeed after the god awful quality of teaching I had at uni, cut the poor kid some slack and help him figure out how much of a mess this is. Shaming a newbie on reddit isnt doing anyone any favours other than demoralising him if he found out.

31

u/katafrakt Jan 23 '20

Surely finding this on reddit in few hours will help him with his career and self confidence...

3

u/fynn34 Jan 24 '20

This is the reason for my downvote, I’m hoping to keep it off the poor dev’s reddit and hopefully keep from giving him a complex for the rest of his career.

16

u/rco8786 Jan 23 '20

Jr devs write bad code sometimes. Use it as a teaching opportunity.

8

u/[deleted] Jan 23 '20

This still shows a high order of understanding of programming, it just missed a mark. It shows an understanding of (or at the very least an ability to use): Arrays, indices, iteration, offsets, and object orientation... in 3 lines. Is this the best way to solve the problem? Well, no, any experienced programmer can tell you that, but what I see here is a strong ability to program with a lot of potential, minus the experience.

3

u/upfkd Jan 23 '20

This is not junior level. madeup/10

2

u/totallysafefork Jan 23 '20

But... why?!

First the array of numbers from 1 to 6 inclusive, then initializing the iterator to 1 while ALSO making the set exclusive of the written upper bound. You could also include the definition of ret in the loop initializer... there’s so much wrong with this I can’t start.

9

u/SinisterMinister42 Jan 23 '20

I think we all went through that point of programming where we write some code, it doesn't work, write some more code, still doesn't work, and then we keep making changes that we don't even understand until we get the results we want. This code here looks like the result of that style of programming. It's not what a professional, paid programmer should be doing but I think we've all been there at one point.

7

u/[deleted] Jan 23 '20

Those who say they haven't either are here for the memes or have never programmed themselves. Alternatively they're, you know, very self absorbed.

2

u/Taksin77 Jan 23 '20

I get the issue with the index but could someone be kind enough to explain in details. Pretty please. Not a c# programmer here.

1

u/TastyDumplingSoup Feb 07 '20

Look at the array.

3

u/jmack2424 Jan 23 '20

Works on my machine.

Badly.

1

u/ev_dev Jan 23 '20

My eyes are burning.

1

u/jujuspring Jan 29 '20

Code reviews?