Yes it's useless but it's all syntaxically correct. I understand why they put useless code in ads cus u can't really fit a whole lot of useful code in a png.
For this ad, they made something that would work, so I think it's fine
The variables are unnecessary, but It’s the int x = 3 that gets me. Clearly a placeholder for user selection, but this will only return the one switch statement here.
If they had to keep the variables, I would have put them in an array myself, just makes more sense.
Not so bad as a learning tool, but I'd use a real-world example like `iAgeAlice`, `iAgeBob`... etc. and output their name instead of the number. Even if newbies understand the code, they'll think coders must be pretty stupid.
What I’ve noticed with programs like in the OP is that new programmers will think the computer can tell what the name of a variable means. So iThree means 3 and don’t actually understand that iThree is a random variable name that could any value of any value type.
I don't think it's so much a bad code as much as it's someone who wanted to show a switch but simply lacked the imagination to come up with a more realistic scenario in which to use it.
My father still uses this variable naming convention and it's how he taught me. He said that he really likes just being able to look at the variable and know what it is without having to look around for the declaration (or mouse over it in a modern IDE).
Well your dad and all the gurus of programming in ancient times got it wrong. The type hint won't help you much, instead you should simply name your variables something meaningful like number_of_customers instead of iCstm. But back in those days people didn't have keyboards, only stone tablets and chisels and it was a lot of work to write descriptive names.
Not sure what makes you think there's any sarcasm here. Maybe you should read a book sometime. Historically speaking, the progression of coding went Stick and Sand (1985) -> Stone Tablets and Chisels (1995) -> Windows 2000 (2000 believe it or not).
My dad said when he was starting out, back before Jesus was crucified, they didn't even get chisels; they had to use animal teeth instead. And if you hadn't caught enough saber tooth tigers... you had to use your own teeth!
I mean - to be fair back then they'd have limits on line length as well to fit monitors so you couldn't luxuriously name things as long as possible for readability purposes.
yeah, great example to read code with hungarian prefix naming is half-life source code :D I started programming with modding this game and sometimes I do it out of habit. But it has some advantage - you do not must use inteliisense to look what variable it is
You wouldn't, but the name gets stuck in your head, and later on it will randomly be retrieved when you're ransacking your brain for tutorials you know of, and your brain won't have stored the reason why the name got stuck in your head. It's surprisingly effective as a marketing tactic.
88
u/batleram Sep 10 '21
I don't really see a problem with the code.
Yes it's useless but it's all syntaxically correct. I understand why they put useless code in ads cus u can't really fit a whole lot of useful code in a png.
For this ad, they made something that would work, so I think it's fine
207
u/Akantor47 Sep 10 '21
Well, i mean at least it would be easy to change iONE to a different value whenever you need to produce a annoying bug for your coworkers.
iONE = 3
I three = 1
x = 1 output "three"
97
u/BarryFruitman Sep 10 '21
Not so bad as a learning tool, but I'd use a real-world example like `iAgeAlice`, `iAgeBob`... etc. and output their name instead of the number. Even if newbies understand the code, they'll think coders must be pretty stupid.
5
u/Stegocephelia Sep 10 '21
When you take avoidance of magic numbers too seriously.
3
u/Rainbow-Dev Sep 10 '21
I thought it was better to use std::cout in C++ instead of puts? Also those consts should probably be in an enum
5
u/0x3fff0000 Sep 10 '21
Why not just use itoa()?
2
u/Kapten-N Sep 11 '21
I don't think it's so much a bad code as much as it's someone who wanted to show a switch but simply lacked the imagination to come up with a more realistic scenario in which to use it.
1
u/OwnStorm Sep 11 '21
Overachiever manager at Linkedin made this...
1
u/Naahun Sep 11 '21
I mean an enum would be better.
1
u/veedant Sep 11 '21
puts? really linkedin?
1
u/iiMoe Sep 11 '21
Isn't that Ruby ?
1
u/GLIBG10B 🐧 Gentoo salesman🐧 Nov 04 '21
The Hungarian notation though
1
u/oxetyl Sep 10 '21
Not really "bad code", it's an example that isn't used for anything
1
u/Knuffya Sep 11 '21
uninstall facebook.
-19
u/loradan Sep 10 '21
I think the bad code was that someone was on FB 🤣🤣
0
u/[deleted] Sep 10 '21
[deleted] — view deleted comment
0
u/[deleted] Sep 11 '21
[deleted] — view deleted comment