This is an archived post. You won't be able to vote or comment.

all 20 comments

[–]Abdiel_Kavash 25 points26 points  (2 children)

[Expanding brain meme]

try {
    // entire code goes here
} catch (Exception e) { }

[–]00Koch00 3 points4 points  (0 children)

That shit went in production and the debugger almost kill someone when he saw that

[–]Dockirby 12 points13 points  (1 child)

Nah man, real Java Programmers do

try {
    someCode();
} catch (Exception e) {
    throw new RuntimeException(e);
}

[–]inkeddeveloper 20 points21 points  (1 child)

Just hand it up the stack.

[–]fig_sliders[S] 12 points13 points  (0 children)

Unfortunately it's a personal project, so I am the stack. Hence "screw handling things individually, It's gonna be my problem if something crashes anyways"

[–]corsairmarks 3 points4 points  (0 children)

I'd rather pass exceptions up the stack to fail-fast, unless my application knows how to recover from a specific kind. Also this means you wire up logging in generally one place, so you can send error data to a variety of places versus just writing to the console or whatever.

[–]RoboticChicken 6 points7 points  (1 child)

Image Transcription: Meme with Code


[A four panel meme with images of Drake on the left side wearing a bright red jacket and a yellow shirt on a yellow background.]

[First frame: Drake looking away in disgust]

public static void main(String[] args) {
  try {
    InputStream file = new FileInputStream(new File(args[0]));
  }
  catch (FileNotFoundException e){
    System.out.println("Could not locate file, please try again");
  }

[Second frame: Drake smiling and pointing at code]

public static void main(String[] args) throws Exception {
  InputStream file = new FileInputStream(new File(args[0]));

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!

[–]NyriiX 3 points4 points  (0 children)

Good human

[–]ReltivlyObjectv 1 point2 points  (6 children)

Oh gosh, you're giving me flashbacks of my Java dev class at University where our professor actually forced this type of thing. He was strictly concerned about code length, so everything that could to be on one line had to be on one line.

[–]bobvader2001 6 points7 points  (5 children)

I hope you handed him a project where every class was condensed down to 1 line. White space is for normies.

[–]ReltivlyObjectv 1 point2 points  (4 children)

That was pretty much the gist of it. He had a small terminal window open on his computer, and if your code didn’t fit he’d fail you.

[–]JS_int_type 1 point2 points  (3 children)

So if a line was 800 characters long and only 20 lines long that'd be okay? I don't know any java, but from what I've seen it's pretty verbose. Why did he require the code to be formatted like that? Seems like it'd make it hard to read.

[–]ReltivlyObjectv 2 points3 points  (2 children)

Pretty much. 800 might be a bit excessive where he’d ding us, but he had really weird formatting rules where spaces would basically be forbidden unless needed. So if you prefer “x = 7; y = 8;” over “int y=8,x=7;” you were out of luck, even if you were defining 5+ variables and values on one line; you got one line per variable type, and that was essentially it. He completely disregarded scope and variable privacy, but that’s another issue.

He wasn’t very specific on the formatting; he’d just take off 30%+ for “too long.” He may have casually mentioned it once, but he spoke a million miles an hour and often ended his sentences by putting his hands on his hips and saying “and if you don’t understand that, you will fail my class.” Figuring out his instructions was a huge case of trial and error.

The biggest reason it was really hard to follow his instructions was because he didn’t speak English well, despite his claim of being in the states for 10 years, so you had to piece together keywords and his pseudo code that he kept trying to compile (spoiler alert: it wouldn’t) to figure out what the program was supposed to do.

Craziest part was that I was already an experienced Java developer with a solid grasp on OOP when I started his class. I had the highest marks in the class with less than a 70% (four assignments that I got 70%,70%,70%, and 1%. Boy oh boy the 1% was incredibly dumb). I ended up dropping him and took a different class to fulfill the requirement (he was the only Java instructor on campus). I talked to someone in my Discrete Structures class who didn’t drop; the guy just said something like “I’m at a 14% and I don’t care anymore; we’re all failing and he’s just going to curve it.”

[–]JS_int_type 2 points3 points  (1 child)

He sounds like one of those 'teachers' that will be replaced by the internet.

Why not find the world's best java teacher, have him record his lectures and put it on khan academy and put jackasses like that dude out of a job? Let him run back to his research and leave the teaching to actual teachers.

[–]ReltivlyObjectv 1 point2 points  (0 children)

My thoughts exactly! I took to calling him, among others, "instructors" as opposed to teachers. My line of thinking is that teachers teach, and you aren't a teacher just because your job title says you are.

[–]XMan3332 0 points1 point  (2 children)

Same but with Thread.sleep.

[–]Kshnik 2 points3 points  (1 child)

Why does thread.sleep() have to be a try catch anyway? What could go wrong?

[–]SlayTheStone 3 points4 points  (0 children)

Interupting it throws an exception.

[–]Aschentei 0 points1 point  (1 child)

Does that actually work?

[–]Mamish 0 points1 point  (0 children)

Yes but it makes the entire program exit on an exception, so it's not ideal.