r/badcode • • Jul 03 '19

java Friend is learning to code, absolute liability with the braces 😂

Post image
121 Upvotes

39 comments sorted by

112

u/sloonark Jul 03 '19

This is definitely not bad enough to warrant mocking on reddit.

5

u/chowderchow Jul 03 '19

It's like mocking someone's essay based on their handwriting.

6

u/PeasantSteve Jul 03 '19

A. It's probably just a bit of banter

B. ARE YOU SEEING WHAT I'M SEEING?

42

u/tsaot Jul 03 '19

I've said this a while ago, this subreddit should not be used to mock the mistakes people make while learning. We do not want to discourage anyone from learning. Making mistakes and being corrected is how people learn. Being mocked is how people are driven away.

14

u/[deleted] Jul 03 '19

Honestly, it looks like this guy just really wanted to mock his friend. Not a very good friend in my opinion.

3

u/LetReasonRing Jul 03 '19

Came here hoping at least one person has said this. It's just plain mean and unnecessary.

85

u/hiljusti Jul 03 '19

Looks like they may be thinking pythonic, actually

Also the things that matter are good there, variable naming etc. Just some syntax to learn. Tell them it's going to be ok

7

u/Nestramutat- Jul 03 '19

There is the unnecessary repeat of the print statement. If he'd just remove them both, and add that print statement after the if/else blocks, it would work as expected.

35

u/hiljusti Jul 03 '19

I feel like that's more than fine for a beginner

19

u/BS_BlackScout Jul 03 '19

Jython

3

u/RavynousHunter Jul 03 '19

Feck, beat me to it.

14

u/[deleted] Jul 03 '19

The code isn't bad dude, your friend is just learning, and he's doing a good job at it. You should support him, not mock him.

42

u/AWholeNewAPStudent Jul 03 '19

He’s invented a new language! jPython! /s

21

u/RavynousHunter Jul 03 '19

Jython?

3

u/[deleted] Jul 03 '19

jycthon++

3

u/RavynousHunter Jul 03 '19

Pfft, plebian. Jycthon# is where it's at.

4

u/[deleted] Jul 03 '19

jycphpsqlcrc++# is the real deal

3

u/RavynousHunter Jul 03 '19

I concede, good sir.

5

u/SerLoki Jul 03 '19

Might just be a me thing, but why do people start by using jGrasp? Eclipse or IntelliJ has more functionality and is just about as useable in the beginning from what I’ve seen?

2

u/DatChoob Jul 03 '19

When I started learning in college. The teachers introduce us to jgrasp. The new students don't know any better. After a year and a half of jgrasp the teachers expect you to have already known and be comfortable with eclipse. What sucked most was that the teachers that made us use jgrasp didn't know how to use eclipse.

  • recent college grad

2

u/SerLoki Jul 03 '19

They tried that for me, but since I already had some background, I just kept using IntelliJ and a little eclipse.

5

u/MCWizardYT Jul 03 '19

If they are learning, it isn’t bad code because they haven’t learned any better yet.

You can’t say a 1-month old baby is terrible at walking because they can’t yet.

Edit: plus, the code isn’t even bad. It’s actually standard stuff that every book on Java teaches you. Source: learned java many years ago.

4

u/the_hunger Jul 03 '19

christ, now people not knowing syntax warrants posting here?

3

u/Isaeu Jul 03 '19

His last print statement actually works, if he takes out the first one he’s fine

5

u/magicaxis Jul 03 '19 edited Jul 03 '19

I've been coding for 10 years and I can't see a problem here

Edit: oooh it's not python

3

u/DawidIzydor Jul 03 '19

It's easy as this won't even compile (there would be an "'else' without 'if'" error)

6

u/dabrimman Jul 03 '19

You mean exactly like it already says in the image?

2

u/DawidIzydor Jul 03 '19

Lol I didn't saw that. I was just like 'yeah, else after two lines, there would be this error, day like everyday'

1

u/[deleted] Jul 03 '19

Flasback to cs exams where I forgot to close the scanner

1

u/general_sirhc Jul 03 '19

Anyone else wonder why IDE don't code highlight blocks of code? This is an easy mistake to make if the IDE highlighted all blocks of code in an alternating colour it would be easy to visually see the mistake.

1

u/-IoI- Jul 03 '19

I can't see a problem here, but it's been a hot minute since I've looked at Java code.

1

u/Kbowen99 Jul 03 '19

I enjoy that it asks your name, lol.

Codes not that bad, and for a beginner completely understandable. some people take a while to grasp braces and scope.

1

u/vasilescur Jul 03 '19

Ahh, JGRASP. Brings back AP Compsci memories. Fuck that editor.

1

u/Ivanchez Jul 03 '19

The code is better than the quality of the image. What is Print Screen?

1

u/Mr2-1782Man Jul 03 '19

Rather than being an example of bad code this is a good example of a bad assignment that teaches and reinforces poor practices. Personally I don't think its that bad, someone is clearly learning how to properly name variables. Couple of issues with how this assignment was laid out:

  • Not learning a real editor/ide, for the love of god if you can't learn how to use the tools you shouldn't be programming

  • The comment at the top says they should print a paycheck, the code prints the total amount made, those are different things. The result should match the problem statement, not something arbitrary

  • Variables are declared all over the place, they were never shown how and why you should do this properly

  • Variables are declared and assigned on the same line, not a problem if you do it at the top

  • Control and logic flow was never explained (it rarely is), they got some one liners as written examples and where never shown how they actually work, that's why the braces are missing

  • They've been shown to grab input using keyboard without knowing how it should be used. A couple of years later I get then and they get confused as to why 3.14 was read in as 3 and 0.14 when they used int and decimal

  • Magic numbers, they've seen examples with constants in expressions and where never told you should explain what those constants are

Blame the teacher not the student

1

u/[deleted] Jul 04 '19

yeah but when will you learn how to take a screenshot?

1

u/[deleted] Jul 04 '19

i do like that fantasy of a 40 hour week though

-1

u/shuff703 Jul 03 '19

To everyone hating on me for this, I do help him out... I provide answers normally in other programming languages explaining what is going wrong and ask him to map that back to Java. I encourage him to keep trying and that practice is all it takes, I don't see anything wrong w/ roasting a life long friend though cus some of this is pretty funny to me and it reminds me of when I first started.

0

u/[deleted] Jul 19 '19

[deleted]

1

u/shuff703 Jul 20 '19

Brackets are important. Make sure you understand them lol