r/learnprogramming • • Mar 22 '22

Don't be that guy.

I just took over a project for a guy who left. Don't be this guy:

  • ZERO comments in your codebase.

  • One and two character variable names with no discernable pattern.

  • Comment characters used to comment out big chunks of code for no discernable reason.

  • No error checking.

  • Reliance on data files that you forgot to include or explain, going in to meaningless data frame names.

  • Making outrageous claims about how much your code improves things with zero baseline performance.

People like this think you're an idiot because you can't make their code work, and get to be all smug. We will track you down and find you. You will need references someday....oh my.

2.6k Upvotes

427 comments sorted by

View all comments

119

u/biggamax Mar 22 '22 edited Mar 22 '22

Going to play the Devil's advocate here. Although it's likely the coder/work you're slagging off publicly deserves it, you're coming in after the fact and armchair quarterbacking. Criticizing the guy/code is low hanging fruit. Getting to work and improving the situation (instead of venting on Reddit) is where you can show real value.

What you haven't told us:

- What requirements was the dev working against?

- What timeline did the dev work under?

- Did the dev have enough help on his/her team?

- Was there intentional tech debt for a good reason that was beyond his/her control?

- Was the dev spread thin on many tasks, or was this code his/her sole responsibility?

52

u/[deleted] Mar 22 '22

I'd upvote this twice if I could. I'm learning programming in my free time, currently work in residential maintenance. I'm on a team that's supposed to have 5-6 on staff, responsible for two high rise apartment buildings and over 500 units. There's only two of us on staff. Basically a third of the staffing management decided was necessary for the building to operate. Our budget for the year was blown by the overreach of the previous team, so we can't make purchases without special authorization. No OT is approved, so we have to do the work of a full team with only 80 man hours a week between the two of us, 20 of which are accounted for by trash and recycling alone. We've been getting comments all year about how half-assed our work is and how incompetent we must be. The truth is that if either of us was anything short of hyper competent, the whole project would have fallen apart, and what they're seeing is the work of a team capable of better, but forced to do a shitload of mediocre work insanely fast just to keep their heads above water.

Sometimes the idiot who worked on it before was not an idiot, they were simply in an environment that did not tolerate failure and provided inadequate resources for success.

14

u/Independent_Feed5651 Mar 22 '22

I agree and disagree.

One / two character variable names? Unacceptable. That’d have been just as fast to do it right the first time.

Zero comments in codebase? Completely fine.

Everything else ? I could see those being done in a time crunch. Sometimes stuff is messy when you’re doing a proof of concept. (Now I’ve learned that nothing is a POC, everything is ‘final’ product).

5

u/tnnrk Mar 22 '22

I’ve never understood the 1 character variable names. Like why would you do this. Any file size savings you received from removing a couple bytes here and there are not worth the complete lack of readability.

1

u/BeardSprite Mar 23 '22

Laziness and convention, especially if you're talking about CS graduates. At university, these were incredibly common because everyone had to go through a large number of theoretical CS and maths courses, where this was the de facto standard and naming things verbosely is clearly considered a cardinal sin.

I've also seen it when someone with a strong math-y background picks up programming; many times they will start doing the same thing if all they have to do is write short scripts rather than huge applications that need to be maintained for years to come.

1

u/vi_sucks Mar 23 '22

Eh, i make exceptions here for variables that are standard math or commonly used in programming.

If you want to iterate through an array, for(int i = 0, etc) is fine.

Same if you are working with a graph/matrix of some kind and use x,y as coordinate pair.

5

u/purplebrown_updown Mar 23 '22

These are good points but what the OP outlined is just bad programming. But it’s not just their fault. The company should have checks along the way so the programmer can learn.

4

u/biggamax Mar 23 '22

I agree with you, but I think it's a sign of immaturity to have a moan about it to the extent the OP has. Why? Cleaning up a mess like this is a FANTASTIC opportunity in disguise. Get your nose to the grindstone. Impress. Show results. Based on his/her comments, I'm not convinced he/she is up to that task. And, as another commenter in this thread has said, even superstars can be dulled into oblivion if the organization around them has adopted bad practices which have doomed the entire organization to fail.

3

u/purplebrown_updown Mar 23 '22

That’s a fair point too. It goes with the territory and it’s where the rubber meets the road. Everyone who’s coded long enough has been through this.

1

u/biggamax Mar 23 '22

Do I sound jaded, much? ;)

3

u/lykwydchykyn Mar 23 '22

So true, there is always another side to it. I've encountered code that was intentionally obfuscated or poorly written, but I've also been in situations where I jumped to the conclusion that something was obfuscated or over-engineered when the truth was I just didn't understand the problem being solved or the constraints that had to be worked around.

It's easy to get self-righteous as a coder and think your own code is a work of art and everyone else's is crap. Eventually we all have the experience of looking back at our old code and realizing we were never all that.

-4

u/BullCityPicker Mar 22 '22

Ha ha ha. Like I could possibly know ANY of these things? I don't even know where the data files for the code are.

This excuses many things. However, if the only use of the comment character in the entire code base is "I don't want this code to run for some reason", there's no excuse for that. I doubt I've ever written twenty straight lines of code without a comment in it. To be fair, I am a pretty verbal person who minored in English.

3

u/dphizler Mar 23 '22

The point is that you don't know. Heed the advice and get to work.

2

u/biggamax Mar 22 '22

Have you cleaned up the project yet?

1

u/rexvansexron Mar 23 '22

thanks for making me put my pitchfork away.