this post was submitted on 28 Mar 2024
4 points (100.0% liked)

Programmer Humor

32558 readers
501 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
top 13 comments
sorted by: hot top controversial new old
[–] BatrickPateman@feddit.de 0 points 8 months ago

Great. Now that my code is self-documenting it is somehow also not legible?

Make up your damn minds, peeps!

[–] Fraqual@feddit.de 0 points 8 months ago

Deobfuscated code

[–] hstde@feddit.de 0 points 8 months ago

This is something that can easily get refactored, because the purpose of alia the variables is right there in the name. This is way better that spending three days to try to figure out what the purpose of var1 is.

[–] Hupf@feddit.de 0 points 8 months ago
[–] warlaan@lemm.ee 0 points 7 months ago* (last edited 7 months ago) (1 children)

The real naming fail is calling the class "GameManager", still my number one pet peeve. With a class name as vague as that you would have to add tons of information into the variable name. (Also the class name begs for unorganized code. I mean name one function or variable that you could not justify putting into the "GameManager" class. After all if it's managing the game it could justifiably perform any process in the game and access any state in it.)

Once you put the first bool into a class with a name like AccessibilitySettings, calling it something like HighContrast is completely sufficient.

[–] Dragster39@feddit.de 0 points 7 months ago

With a class name as vague as that you would have to add tons of information into the variable name.

Technically they did exactly that.

[–] NeatNit@discuss.tchncs.de 0 points 8 months ago (1 children)

gestures at ~~butterfly~~ this code

Is this self-documenting code?

[–] skulblaka@startrek.website 0 points 8 months ago (1 children)

I genuinely believe something like this is what some of my professors wanted me to submit back in school. I once got a couple points off a project for not having a clarifying comment on every single line of code. I got points off once for not comment-clarifying a fucking iterator variable. I wish I could see what they would have said if I turned in something like this. I have a weird feeling that this file would have received full marks.

[–] maniclucky@lemmy.world 0 points 8 months ago (1 children)

Did you have my professor for intro to C? This guy was well known for failing people for plagiarism on projects where the task was basically "hello world". And he disallowed using if/else for the first month of class.

[–] OneCardboardBox@lemmy.sdf.org 0 points 8 months ago (1 children)

Reminds me of an early Uni project where we had to operate on data in an array of 5 elements, but because "I didn't teach it to everyone yet" we couldn't use loops. It was going to be a tedious amount of copy-paste.

I think I got around it by making a function called "not_loop" that applied a functor argument to each element of the array in serial. Professor forgot to ban that.

[–] CileTheSane@lemmy.ca 0 points 8 months ago (1 children)

but because "I didn't teach it to everyone yet" we couldn't use loops.

That is aggravating. "I didn't teach the class the proper way to do this task, so you have to use the tedious way." What is the logic behind that other than wasting everyone's time?

[–] skulblaka@startrek.website 0 points 7 months ago (1 children)

Teaching someone the wrong way to do something frequently makes the right way make way more sense. Someone who just copy/pasted 99 near identical if statements understands on a fundamental level when, why, and where you use a for loop much more than someone who just read in the textbook "a for loop is used to iterate elements in a collection".

[–] ICastFist@programming.dev 1 points 7 months ago

Reminds me of a dude that wrote the equivalent of this in Visualg (a brazilian pseudocode language and program, meant solely for teaching programming)

if
  if
    if
      if
        if (x < 10) then
          print(x)
        else
      else
    else
  else
else

That the thing ran and didn't complain about the amount of loose/needless if's checking fuck all baffles my mind to this day.