Prepared for the Real World

"Now, this is a wrapper around a PreparedStatement, so guess how most of the methods work…"

had that awful inevitability of what is about to happen when somebody is sitting next to you (or worse, opposite you) says, "I'm going to throw up," without actually making a move to do anything about it.

Ignoring how most of this class is just a thin wrapper that still breaks any advantage of using a wrapper in the first place, exactly 0 lines of this class are even needed. Java has auto-closing resources since 7, meaning that you just need to name the resource in the try statement. And since most (if not all) of the functions can throw exceptions anyway, there's got to be a try statement somewhere anyway.

All in all, this is just a show of ignorance of the language's features. On top of being bad code.

somethingFinalized is nowhere read in the code. Based on its name, the static modifier, and its public access I'd guess it is used by some external code to check whether any of the classes instances was ever finalised.

Still, that wrapper makes for an interesting piece of code, especially in light of try-with-resources (as ray10k mentioned earlier).

Looks didactic. Student's code can check whether the trick ever worked using this. Why? Why not. Not a bad idea as such if the code is only for use in classes. Doesn't make the code any less of a WTF though.

If the professor for my capstone course had given me this code, I would have asked him to his face why he bothered to write 1300 lines of absolute nothing instead of just extending the original class and providing a new function.
Then again, I got into arguments like this with my professors all the time when they did totally retarded things because they'd clearly never been outside of academia. Best response I ever got:

"It is not the student's role to question the professor or argue about methodology."

I reported him to his department head. The student's ONLY role is to question the professor.

I don't know when the professor's code originates from, but as of Java 7, the language has built in facilities to automatically close resource handles when you're done with them. It's called try-with-resources: https://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html

Anything that implements AutoClosable can be used in a try-with-resources block, and it's easy to extend, so you can easily add it to your own objects that have resource handles.

You can place multiple resources in the same block if desired, so you could immediately get your ResultSet right after the PreparedStatement in that same try() block. You probably wouldn't, since I would presume that you would need to bind variables, but there are situations where chaining them helps.

Brings back memories of my 370 Assembler class back in 1990, where we wrote Assembler code to run in an interpreter the professor wrote in GW-BASIC, and I broke by just doing a little code that went just beyond what his stupid interpreter could handle.

Oh please.... I've inherited the system full of those WTFs. The professor is prepping them for real world. The real world where this kind of shit is not only allowed but probably even celebrated because in the end - if it works, its perfect. Just one of the projects can produce years of WTF supply for this site. The fun part, the guy responsible now works at one of the biggest banks who were part of fed reserve managing, as he so proudly put it, "team of indians". So yeah, all that shit is perfectly normal.

Oxford: "in British English, all of the following spellings are acceptable: finalize/finalise; organize/organise; realize/realise. In American English, the only correct spellings are finalize, organize, and realize."

Considered globally, -ize is never incorrect and -ise is sometimes incorrect, therefore -ize is better.

Not defending the code as it is pretty moronic. As someone who's wife taught computer science while getting her PHD and someone who works at a national research laboratory I can give some insight into the situation.

For one the actual professor for the course probably did not write that code. They probably had one of their teaching fellow, teaching assistant or unpaid intern write it for them. The teaching fellow, teaching assistant or unpaid intern probably took an introduction to Java class and that is the extent of their experience with the language. The professor probably never bothered to look at the code the teaching fellow / teaching assistant / unpaid intern wrote for them and just asked if it worked. You might say the professor is pretty uninterested in how the code works and by extension the education of their students. You would be right. That is because if the professor is at a research university he / she primary job is to get research grants and conduct research which is very profitable to the university and themselves. If the professor ever wants to get tenure they better be getting grants and lots of them. Teaching classes and dealing with students is a gigantic waste of time for them so therefore they spend the least amount of time / energy possible on it.

Think about that the next time you blow $400K on your kids education at a fancy university.

If the professor for my capstone course had given me this code, I would have asked him to his face why he bothered to write 1300 lines of absolute nothing instead of just extending the original class and providing a new function

Oh, that part's easy. PreparedStatement is only an interface - the implementation is provided by whatever actual database driver you're dealing with - so extending the class and adding new methods won't achieve anything.

That said, the "correct" way to implement this WTF would be to use a reflective proxy to do method pass-throughs instead of manually implementing every method in the class. It would still be a stupid idea, but it'd be about a dozen lines instead of 1300, and wouldn't need updating whenever new methods are added to the interface.

(I know this from experience having encountered code very similar to this before, and having successfully used such proxies at a first step to cleaning up the mess)

I once worked for a state agency where the Indian lead did this except with every .NET framework that he could get his filthy mitts on. He stored "his" framework in a locked repository and frequently checked in non-compiling code before taking a 4-day weekend. Daily pulls were mandated so 3-4 days every other week were wasted. Of course, the project being years behind was the fault of a revolving door of new hires/fires who just didn't understand how busy he was needfully reverting about 10 whole e-mails per week.

The real WTF is that it took them until version 7 to add this. People go on and on about how much work garbage collectors save you, totally ignoring all the extra work they create when dealing with anything that isn't RAM.

That adage applies to veterans of a trade no longer being able to perform it, so they retire to teach the next generation. It has nothing to do with inept people teaching. A better way to frame the adage is "Those who are no longer able, teach".

No, TRWTF is the US thinking they own the world and can change all the agreed-upon conventions.
"Let's change all the spellings that everyone else uses!"
"Let's use outdated units of measurements that no one else uses!"
"Let's use a nonsensical date format that no one else uses!"
etc. etc.

Plus... "Let's name ourselves the same as an entire pair of continents!"

A. Webster was RIGHT when he took all those silent 'u's out because words should be spelled like they sound! I wish he'd won with "soop" too.

B. The units weren't outdated when we adopted them, and they still work just fine. I believe the expression is "if it ain't broke, don't fix it".
It really isn't our fault you got shanghaied by the french into changing all your numbers, so just let go of your globalization worries, head down to the pub, and down a pint... I mean a 0.57 liter.

Yes, and you'll note that the spelling isn't broken, so why bother fixing that? There are plenty of words that the US hasn't "fixed"... if you're going to try to "fix" the spellings, then go all the way rather than stopping after four rules.

Fun fact: approximately 4% of people live in the US. That is nowhere near enough reason to insist on changing things (for the worse)

Oxford: "in British English, all of the following spellings are acceptable: finalize/finalise; organize/organise; realize/realise. In American English, the only correct spellings are finalize, organize, and realize."

Considered globally, -ize is never incorrect and -ise is sometimes incorrect, therefore -ize is better.

You are incorrect. "Acceptable" is not the same as "correct". "-ize" is incorrect but acceptable in English English, but "-ise" is unacceptable to the rigid American English speaker.

As one who recently made a late-life career change from software development to teaching, I live in constant fear that these's some complete misconception I've had for 30 years that I'll now be passing down to my students, and which I'll someday find on this site.
Luckily, some of my students are insanely bright HS kids who love correcting every mistake I make on the board, so maybe they'll help prevent that from happening.
(BTW, that last statement was not sarcastic; I'd rather have my mistakes corrected than live forever in my students' notes.)