this post was submitted on 29 Nov 2023
0 points (NaN% liked)

Programming

17318 readers
73 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities [email protected]



founded 1 year ago
MODERATORS
 

I'm studying programming, and I don't agree woth my teacher. She basically said that if we use break (and continue too maybe) our test is an instant fail. She's reasoning is that it makes the code harder to read, and breaks the flow of it or something. (I didn't get her yapping tbh)

I can't understand why break would do anything of the sorts. I asked around and noone agreed with the teacher. So I came here. Is there a benefit to not using breaks or continues? And if you think she's wrong, please explain why, briefly even. We do enough down talking on almost all teachers she doesn't need more online.

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 0 points 11 months ago (1 children)

There is a school of thought that break and continue are just goto in disguise. It helps that these two are more limited in scope than goto and can be considered less evil. If you read the book Clean Code by Robert Martin (it should be required reading for all developers), you’ll see that he doesn’t like functions to be very long. I think his rule is no more than 4 lines. I try to keep mine around 10 or less with a hard stop at 20 unless it can’t be avoided because I’m switching over a large enum or something. If you put your loops into functions then you can just use return instead of break.

I did have a discussion with a teacher once about my use of early returns. This was when I had returned to school after many years as a professional programmer. I pointed out that my code has far less indentation than theirs and was simpler because of it and that it is common in the world outside of education. I got all of my points back he has deducted.

You’re going to hear some good and bad advice from your teachers. Once you have a job check out what the good developers are doing and just follow them.

[–] [email protected] 0 points 11 months ago (1 children)

I wish people stopped praising a book that has been repeatedly debunked as dogmatic, outdated, nonsensical garbage.

No, do not bother with Clean Code. Been there thinking it was some bastion of truth that just went over my head. It's not. Fuck uncle bob.

[–] [email protected] 0 points 11 months ago (1 children)

I don't know your or his source, but warning me before I read it deserves a thank, so thanks for saving me time.

[–] [email protected] 1 points 11 months ago

this is only scratching the surface of the turd iceberg, but here: https://qntm.org/clean