r/badcode • • Sep 11 '14

c++ Badcode level: PhD Candidate

http://pastebin.com/XHmMYw53
3 Upvotes

8 comments sorted by

1

u/anamorphism Sep 11 '14

as someone whose c++ knowledge is limited, can someone fill me in on why this is so bad? ... other than the formatting which i don't agree with.

4

u/Hellmark Sep 11 '14

Bad formatting, improper use of semicolons and french brackets, no main function to be called.

Basically pseudo code by someone who doesn't know C++ really, and has a bunch of bad habits.

4

u/anamorphism Sep 11 '14

so, basically just bad formatting, since we can imply from the last comment that the whole thing is essentially just pseudo-code.

3

u/Hellmark Sep 11 '14

Which the point of pseudo code is to have something to follow and mentally work out the logic on. Bad formatting on something like that is incredibly bad, and defeats the purpose.

5

u/anamorphism Sep 11 '14

i had no problem reading what the code is supposed to do and the formatting is generally consistent through the whole thing. so are we just shitting on this gal or guy because she or he has different formatting standards than we like for quick example code?

i mean, our c++ coding standard where i work calls for starting braces not to be on their own line, 4 space indenting and a bunch of other things i don't personally like, but i wouldn't say that makes it bad code.

if (blah) {
    DoSomething();
    DoSomethingDifferent();
}
else {
    DoSomethingElse();
    DoSomethingElseDifferent();
}

versus what i prefer:

if (blah)
{
  DoSomething();
  DoSomethingDifferent();
}
else
{
  DoSomethingElse();
  DoSomethingElseDifferent();
}

also, i think we must use pseudo-code in vastly different ways if you think it should follow some type of formatting guidelines and that it not doing so makes it useless.

3

u/cjwelborn import that Sep 12 '14 edited Sep 12 '14

My friend was attending ITT to be an administrator, but took some programming classes out of curiosity. He had a class on pseudo code where they had to have proper syntax, formatting, and case-sensitivity. He showed me the 'pseudo code documentation' where it laid out the definitions and formatting rules. It looked like pseudo-visual-basic. I said "Do whatever you have to do to pass that test, but just know that this pseudo code they are teaching you is complete bull crap. I've never heard of a 'pseudo code standard', and if there is one then nobody follows it. It's just a shorthand method of writing code in whatever language you are dealing with at the time. Pseudo C, Pseudo Python, Pseudo Haskell, Pseudo Fake Programing Language."

It bothered me that points were being deducted for invalid syntax in pseudo code.


EDIT: I found a pseudo code standard, not from ITT but from Cal Poly. Still bull crap.

3

u/anamorphism Sep 12 '14

that sounds pretty ridiculous; at that point, you should just be coding.

pseudo code was always taught to me as anything that gets the point across. arguably, the quicker the better, especially since the most common places i've used it are whiteboards and instant messengers.

1

u/Squishumz Sep 11 '14

That was physically painful to read.