this post was submitted on 05 Jul 2023
14 points (100.0% liked)

bad code

59 readers
1 users here now

A sub for complaining about bad code, whether you made it yourself or not.

founded 1 year ago
MODERATORS
 
top 3 comments
sorted by: hot top controversial new old
[–] fubo 3 points 1 year ago (1 children)

I once had a programming student do this sort of thing:

done = False
step = 1
while not done:
  if step == 1:
    # ... do something ...
    step = 2
  elif step == 2:
    # ... do something else ...
    step = 3
  # ... and so on ...

Effectively he'd reinvented state machines!

[–] meekah 1 points 1 year ago

Sounds like that student just didn't know how to do it properly yet, but this was done by someone with several years of experience. What he did all those years, however, is a mystery to me.

[–] MurdoMaclachlan 2 points 1 year ago

Image Transcription: Code


    if (startPageNumber >= maxStartPageNumber)
    {
        break;
    }
} while (true);

I am a human who transcribes posts to improve accessibility on Lemmy. Transcriptions help people who use screen readers or other assistive technology to use the site. For more information, see here.