this post was submitted on 29 Nov 2023
-7 points (40.0% liked)

Programming

17111 readers
299 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 !webdev@programming.dev



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
[–] Redkey@programming.dev 12 points 10 months ago (2 children)

Assuming C/C++, dare we even ask what this teacher uses instead of switch statements? Or are her switch statements unreadable rat's nests of extra conditions?

This is a good life lesson. We're all idiots about certain things. Your teacher, me, and even you. It's even possible to be a recognized expert in a field yet still be an idiot about some particular thing in that field.

Just because some people use a screwdriver as a hammer and risk injuring themselves and damaging their work, that's not a good reason to insist that no-one should ever use a screwdriver under any circumstances, is it?

Use break statements when they're appropriate. Don't use them when they're not. Learn the difference from code that many other people recommend, like popular open-source libraries and tutorials. If there's a preponderance of break statements in your code, you may be using a suboptimal approach.

But unfortunately, for this course, your best bet is to nod, smile, and not use any break statements. Look at it as a personal learning experience; by forcing yourself sit down and reason out how you can do something without using break statements, you might find some situations where they weren't actually the best solution. And when you can honestly look back and say that the solution with break statements is objectively better, you'll be able to use that approach with greater confidence in the future.

[–] gazter@aussie.zone 8 points 10 months ago (2 children)

It's a very good lesson- to the point where I wouldn't be surprised if the teacher is deliberately putting an arbitrary restriction on the assignment.

If you want to have a career, the people that pay you are going to make you do things that you consider to be ridiculous. That's work, that's life. You've got three options- Just smile and nod and do it their way, get huffy and tell them that you don't like their yapping and you'll do their project your own way, or politely suggest there may be an alternative way, and ask if they are willing to be flexible with some requirements.

[–] ck_@discuss.tchncs.de 4 points 10 months ago (1 children)

It's a very good lesson- to the point where I wouldn't be surprised if the teacher is deliberately putting an arbitrary restriction on the assignment.

It's not arbitrary. When you start out on a profession, the first thing a good instructor does is make you unlearn the things you already think you know before teaching you the things you need to know. Think of it this way: When you pick up a golf club and start hitting the ball, you'll drive it left and right. First thing you'll be taught is to only hit straight. Even if you think you should try to drive a curve ball, a good teacher will not allow you. Only when you have mastered the basics will he teach you to drive curved balls. So ignore your teachers advice at your own peril, but it will most likely set you up for an expert beginners career.

As a closer, I can tell you this much: I received the same advice almost 20 years ago and now, after being a professional developer for two decades, I can not recall more than five times when a break statement actually made more sense than to rethink the algorithm.

[–] UnRelatedBurner@sh.itjust.works 2 points 10 months ago

You guys have so much faith it's contagious. Very motivational words, Thank you.

[–] UnRelatedBurner@sh.itjust.works -1 points 10 months ago

I've never considered that she might just be very smart. You're very optimistic. Filled me with hope out of nothing. Thanks!

[–] UnRelatedBurner@sh.itjust.works 5 points 10 months ago

last part gave me something of a mindset change, for the better. I'll try being a little less of an idiot then c: Thanks!