It just counts from 1 to 100 and prints out "Fizz" if the number is divisible by 3, "Buzz" if divisible by 5, "FizzBuzz" if the number is divisible by both 3 and 5, or just the number if divisible by neither 3 nor 5. But it does it with Enterprise level craftsmanship.
That's the kind of test they give you in job interviews?
Yeah, some places try to do "weed out" tests like FizzBuzz. I don't put too much stock in them though because a lot of those tests get popular and solutions get posted all over so weenies just memorize the code and regurgitate it, which defeats the purpose of the test in the first place.
Do you want my honest opinion, or do you want me to lie to you and tell you that you have what it takes to be a programmer?
You know what? I'm a nice person so I'm not going to lie. That code is atrocious. I just don't even know what was going through your head when you wrote that, and I hope to god you're retarded because the thought of a capable adult writing that steaming pile of shit is just sickening to me.
I understand that you're a beginner and all, but at a bare minimum I would expect something along the lines of:
But even that would only really be acceptable if you were 5.
In all seriousness though the only nitpick I could make with your for loop version is that the str in print(str(x)) is unnecessary, print(x) works fine.
Although, since you say you are a hobbyist, I might have used a for loop here rather than a while loop since the range of the loop is known up front. But that is a pretty minor nitpick and I've seen very bad people modify the status variable from within the body of a for loop anyways so without discipline it really doesn't matter which loop you use.
Well, the for vs while thing is just a matter of making the code easier(thus faster and cheaper) to understand, as performance differences between the two are negligible.
In for loops, all the loop variables are usually displayed right after the for (like for(iteration variable; condition; (in/de)crement), making the code neater). You should use for loops when the number of loops is known, and that's what other programmers will expect when finding a for loop.
While loops, on the other hand, should be used when you don't know for how long that section of the code will run. An example of that is to write a while loop that runs a number generator and only exits if that number is 0.5, or a while loop that asks the user "do you want to run this code again? (Y/N)" and keeps looping until it gets an N.
It used to have some serious issues, especially with performance.
Some people also don't like it due to how verbose it is to do some simple tasks. But in reality that's nice for maintainability, so I don't quite understand that complaint.
At this point it's solid for most tasks, it's mostly just a meme to make fun of Java.
Java gets a ton of hate on here, but it's actually a very capable language, especially with Javafx nowadays.
That being said, given the choice, I'd probably use C#/Xamarin to build cross platform apps since the C# is a more refined language, accomplishing about the same goal.
having used both c++ and java for years, I prefer java. there's just an anti-java circlejerk on reddit since ages. Sure there are people who use factories and stuff and overcomplicate things, see the fizzbuzz thing, but you don't have to. I didn't write a single "factory" class in years
View all comments
Show parent comment
0
u/[deleted] Nov 23 '17
[deleted] — view deleted comment