That's why all my variables have generic single letter names, using double x you can copy paste it whenever you want, keeping the code clean and documented.
Just want to ask something, isn't #pragma once used to indicate the start of a header file? In which case, does that mean that all the functions are implemented inside a header file? Aren't header files only supposed to contain declarations while the .cpp files will contain the implementation?
If the code is supposed to be self documenting then the local variable that holds the result should have been named according to the math operation being performed, and not simply "sum" every time. For instance, "double difference" and "double product".
The output string should have listed the actual math operation performed; i.e., "10.0 + 5.0 = 15.0", etc. Sort of the way a lot of calculator apps do now.
Don't know if you were using the results, but it seems intuitive for the functions to return the actual results of the math operation. Otherwise, why do you need a double return value?
Still, I wouldn't be terribly embarrassed if this was among the first code I ever wrote.
you say that's dark age? I made a function which returns whether or not a music is playing in my game and if it isn't playing it will call the player function which will check whether or not a music is playing which will call actual function to play music, which by default will check whether or not music is playing. Darkest age of my life...
I remember some of the functions worked,I was proud of myself then I properly learned separate compilation in college which made me remember this abomination
143
u/kbruen Dec 03 '21
Why would
addin particular be returning 1?160
u/TheSuperWig Dec 03 '21
You clearly didn't understand return values lol
Interesting style of same line braces plus an empty line. How to annoy both sides with one simple trick.
3
u/trBlueJ Dec 03 '21
Just want to ask something, isn't
#pragma onceused to indicate the start of a header file? In which case, does that mean that all the functions are implemented inside a header file? Aren't header files only supposed to contain declarations while the.cppfiles will contain the implementation?248
u/[deleted] Dec 03 '21
Most importantly,
WHY DO YOU ADD A NEWLINE AFTER A FUNCTION AND NOT BEFORE ?
Thanks.
29
u/Napain_ Dec 03 '21
yeah but that's just beginners code i think thats a little bit different then bad code
22
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Dec 03 '21
Image Transcription: Code
I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
10
u/Bo_Jim Dec 03 '21
Copy/paste and an absolute minimum of editing.
If the code is supposed to be self documenting then the local variable that holds the result should have been named according to the math operation being performed, and not simply "sum" every time. For instance, "double difference" and "double product".
The output string should have listed the actual math operation performed; i.e., "10.0 + 5.0 = 15.0", etc. Sort of the way a lot of calculator apps do now.
Don't know if you were using the results, but it seems intuitive for the functions to return the actual results of the math operation. Otherwise, why do you need a double return value?
Still, I wouldn't be terribly embarrassed if this was among the first code I ever wrote.
18
u/[deleted] Dec 03 '21
pragma balls
7
u/[deleted] Dec 03 '21
you say that's dark age? I made a function which returns whether or not a music is playing in my game and if it isn't playing it will call the player function which will check whether or not a music is playing which will call actual function to play music, which by default will check whether or not music is playing.
Darkest age of my life...
8
u/FantasticPenguin Dec 03 '21
Why not just override the operators itself?
4
u/speedingpeanut Dec 03 '21
I see worse code in production to be fair
1
u/Servious Dec 03 '21
"why isn't it working??"
2
u/F54280 Dec 03 '21
This one made me laugh loud. Nice work!
2
u/SchattenMaster Dec 04 '21
lol, I didn't even notice return values, just thought about the missed operator overload
2
u/bistr-o-math Dec 03 '21 edited Dec 04 '21
The real crime is to call
x*yasum1
u/il-est-la Dec 03 '21
r/blunderyears
1
u/jhath16 Dec 03 '21
Sum = x - y Lol
1
u/LucasCarioca Dec 04 '21
This seems like experimenting and literally first time coding stuff. Totally normal and expected
1
u/Apocryphenn Dec 04 '21
Real talk, what program is that?? Is that a bat output or vim or something?
1
u/Oman395 Dec 09 '21
Good for learning functions at least
1
u/Oman395 Dec 09 '21
Good for learning functions at least
0
u/Tdoflamingo Dec 03 '21
I mean... If it's stupid but it works, then it ain't stupid.