C++ do while error

Started by
15 comments, last by MarkS_ 9 years ago
Frob, that was very well written and you make a valid point. However, I am just going off of the two code examples he posts. They are fundamentally the same, except one uses classes. If it was clear in his original example that he was intending to expand the scope of the application, then yes, classes would be the way to go. However, he did not suggest that, nor demonstrate it. To me, and this is just my opinion, from the limited data we were given, that he is trying to rewrite the exact same code with the exact same functionality, but with classes. As simple as the code is, what benefits are there to using classes? If your intent is not to expand the functionality, are classes necessary? This example isn't all that far removed from a "Hello World" program.
Advertisement


As simple as the code is, what benefits are there to using classes? If your intent is not to expand the functionality, are classes necessary? This example isn't all that far removed from a "Hello World" program.

Correct. It is a simple program. Classes are an architectural tool to help work within constructs of systems and modules. It does not require classes.

It IS the same as a "Hello World" program, which is why your earlier reply (currently with several downvotes) is inappropriate.

The original poster is clearly learning the basics of the language, they are at the "hello world" stage. They are struggling to understand basic communications with the compiler. If someone is visiting from another nation, and they proudly declare "I speech the English very little. How is said to ... walk in air?" followed by jumping around. You can take the approach -- as you did -- to complain that their grammar is wrong, that their constructs are inappropriate, and that their actions "ruined what was once a fun hobby".

That is not very friendly.

Or you can recognize that they are trying to learn, then do your best to offer support, to teach, to help them.

Their code is about 45 lines or so, all one function. If we were focusing on good design it could likely be reduced to 20 or fewer lines. We could turn it into an exercise of all the ways to make the code "better", more compact, more concise, more correct.

Or we can provide some gentle help to teach and tutor someone who is trying to learn the basics.

tl;dr: When someone is confused about where to put curly braces, complaints about improper OOP and bad design are inappropriate.

The original poster is clearly learning the basics of the language, they are at the "hello world" stage. They are struggling to understand basic communications with the compiler. If someone is visiting from another nation, and they proudly declare "I speech the English very little. How is said to ... walk in air?" followed by jumping around. You can take the approach -- as you did -- to complain that their grammar is wrong, that their constructs are inappropriate, and that their actions "ruined what was once a fun hobby".

That is not very friendly.


Then you misunderstood me and my intentions. That wasn't a jab directed at wabbz111. It was a personal experience directed at no one in particular. I've felt pressure, mostly for people on this forum, to migrate to OOP. So much so, that I caved into the pressure and embarked on a failed journey that ended up costing me a hobby that I enjoyed. Clearly I misspoke. What I was going after was his intentions. Was he doing this because he thought it was necessary, as I have been told in the past, or because he is trying to learn OOP? If it is the latter, then that is fine, but I feel it is the former and given my past experiences, that concerns me. His do/while mistake shows me that he still has some learning to do on basic syntax. Is moving to OOP a good idea at this time? That's what I was trying to get at.

I can explain to him how to fix his do/while mistake, but I feel there is a greater underlying lack of knowledge.

It's not OOP's fault either, though. That's like picking up your car and carrying it to work and then complaining that cars are inefficient.

If someone tries to use OOP because of peer pressure rather than because it's the right tool for the job then the problem is with their peers and the response to those peers, not with OOP itself.

void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

It's not OOP's fault either, though. That's like picking up your car and carrying it to work and then complaining that cars are inefficient.

If someone tries to use OOP because of peer pressure rather than because it's the right tool for the job then the problem is with their peers and the response to those peers, not with OOP itself.


I agree. My response to the pressure was bad. I should have stuck with what I knew. For me, I was so deeply entrenched in ANSI C that C++/OOP was a major system shock. It seemed like sticking with what I knew and was good at was no longer good enough (remember that this is a hobby for me, so it should not matter to anyone else), to the point that I was scared to show code I was having trouble with. It was just too different for me and attempting to unlearn what I already knew to learn OOP burned me out. What I see here reminds me too much of what I went through. I reacted poorly to it. I saw that the original problem had been answered, so I questioned the change to classes. Poorly.

This is not a case of peer pressure. Without asking the op outright I would assume that he is learning as part of a course.

Many c++ programming courses are very heavy on oop very early on for no reason and I agree it is bad form to try and teach oop concepts to someone who hasn't yet grasped the basics of flow control. For this we can't blame the op but should lay the blame squarely on the course material and a culture that tries to make c++ "like java" in classrooms at the expense of simplicity.

With that I believe we've thoroughly derailed this thread, so let's all try to get back on track again :)

With that I believe we've thoroughly derailed this thread, so let's all try to get back on track again smile.png


You are absolutely correct! My apologies!

This topic is closed to new replies.

Advertisement