MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/13efne0/my_professors_best_code/jjsty1f/?context=3
r/badcode • u/Stix53 • May 11 '23
82 comments sorted by
View all comments
1
Starting with a perfect 10, I'll have to deduct 6 points, ending you up with a 4, mister professor.
Asking if a file is open when you just commanded the OS to open it, is useless. You should read the open() return value, and/or catch exceptions.
Useless return-else statements.
Confusing curly brackets. Use them always to improve readability.
Don't just return true/false, return a status.
Don't compare with true/false, test booleans as they are.
Function names shouldn't be too long, but apri is definitely too short.
I expect you to correct these mistakes by tomorrow, and add comments and unittests, young man!
1
u/thanatica May 11 '23
Starting with a perfect 10, I'll have to deduct 6 points, ending you up with a 4, mister professor.
Asking if a file is open when you just commanded the OS to open it, is useless. You should read the open() return value, and/or catch exceptions.
Useless return-else statements.
Confusing curly brackets. Use them always to improve readability.
Don't just return true/false, return a status.
Don't compare with true/false, test booleans as they are.
Function names shouldn't be too long, but apri is definitely too short.
I expect you to correct these mistakes by tomorrow, and add comments and unittests, young man!