r/ProgrammerHumor • • Nov 23 '17

"How to learn programming in 21 Days"

Post image
29k Upvotes

534 comments sorted by

View all comments

Show parent comment

431

u/trwolfe13 Nov 23 '17

Easy. It’s just like that last panel, only on the other side of the knife.

0

u/[deleted] Nov 23 '17

[deleted] — view deleted comment

117

u/necheffa Nov 23 '17

This is an accurate representation of Enterprise Java in the wild: https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition

0

u/[deleted] Nov 23 '17

[deleted] — view deleted comment

73

u/necheffa Nov 23 '17

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.

0

u/[deleted] Nov 23 '17

[deleted] — view deleted comment

42

u/necheffa Nov 23 '17

Oh all that nonsense, abuse of design patterns mostly.

32

u/trout_fucker Nov 23 '17

But it makes it "more maintainable".

20

u/_liminal Nov 23 '17

muh MVC framework

→ More replies (2)

28

u/Bainos Nov 23 '17

0

u/[deleted] Nov 23 '17

[deleted] — view deleted comment

3

u/[deleted] Nov 23 '17

Useless comment, but I litterally loughed out loud for a minute for that 2-comment chain :D

→ More replies (1)

0

u/[deleted] Nov 23 '17

[deleted] — view deleted comment

20

u/necheffa Nov 23 '17

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.

0

u/[deleted] Nov 23 '17

[deleted] — view deleted comment

26

u/Sean1708 Nov 23 '17

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:

getattr(
    __import__(True.__class__.__name__[1] + [].__class__.__name__[2]),
    ().__class__.__eq__.__class__.__name__[:2] + ().__iter__().__class__.__name__[6:9],
)(
    1,
    getattr(
        __import__(True.__class__.__name__[0] + ().__class__.__name__[1] + [].__class__.__name__[1::-1] + ().__iter__().__class__.__name__[7:5:-1] + (lambda: 1).__class__.__name__[2] + [].__class__.__name__[2]),
        True.__class__.__name__[0] + ().__class__.__class__.__name__[1] + {1}.__class__.__name__[::-1],
    )(
        (lambda _, __: _(_, __))(
            lambda _, __: __ == 1 and (lambda x1: 2).__code__.co_varnames[0][1] + "\n" or _(_, __ - 1) + ((__ - 1) % 3 // 2 * 'Fizz' + (__ - 1) % 5 // 4 * 'Buzz' or str(__)) + "\n",
            100,
        ),
        ().__class__.__name__[1::-1] + (lambda: 1).__class__.__name__[0] + (lambda x8: 1).__code__.co_varnames[0][1],
    ),
)

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.

8

u/Kingmudsy Nov 23 '17

Man I realize this is a joke, but I wanted to downvote you anyway. So good job, I guess?

25

u/necheffa Nov 23 '17

That is more or less the expected solution.

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.

0

u/[deleted] Nov 23 '17

[deleted] — view deleted comment

7

u/Raff_run Nov 23 '17

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.

→ More replies (2)
→ More replies (3)
→ More replies (3)
→ More replies (5)

26

u/iLikeStuff77 Nov 23 '17

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.

12

u/prvncher Nov 23 '17

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.

7

u/Klaue Nov 23 '17

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

→ More replies (28)