41

"Fatal Error"
Exceptions? No, let's just halt the entire program.

Apparently a CS professor wrote this code.

"Needed to keep the compiler happy"

Comments
  • 13
    I’m a programmer.

    Are you though?

    Yes, in theory
  • 21
    Still, what bothers me the most in that snippet is the lack of space before the comment.
  • 4
    Why is he using tons of if else just use fucking dictionary or unordered map whatever there is in java(i don't know java)?
  • 2
    clearly whoever wrote that atrocity has no idea what they were doing..
  • 2
    It would make sense if it was written by a CS teacher. Maybe his/her students didn't study the exceptions yet?

    It's fine, it looks like a basic exercise, why should you scare everyone introducing new complicated concepts?
  • 1
    @crisz Then you should use a better example. This is all over the place just very bad practices.
  • 0
    You sure he wasn't a software *engineer* before becoming a professor?
  • 2
    And yet people like this are the people teaching the youth how todo what the PHDs think we professionals do.... we need to get back to professionals teaching the youth and PHD folks back to just writing papers and doing research... cuz they are the reason the youth sucks at programming
  • 0
    @QuanticoCEO

    The youth suck at programming because the youth have always sucked at programming. It's just that for a long time we didn't *know* that because the barrier to entry has been so high for much of the industry (buy an expensive compiler, build your own fucking pc, learn a low-level language like c, etc) even though people's expectations were lower.

    Now, the barrier to entry is *lower* owing to the availability of tools, but people's expectations are *higher*, *much higher* and consequently there are a lot of new tools, and ceremony to learn to accomplish those sorts of things (fucking Babel).

    And of course you have inter-corporate powerstruggles fucking with eachothers tech standards (directx, opengl), and breaking tooling through actual code and legal techniques like lawfare (COCs, etc) to keep their dev bases trapped in each corps portion of the mind ghetto called 'the software industry in 2019' but I digress.
  • 0
    @crisz This was from a higher level SWE course where every student should know about exception handling. The course is currently talking about unit testing. Maybe he wrote it this way on purpose to show why bad code makes it harder to test?

    Regardless, bad design. The month member is a string instead of an integer, yet everything that operates on month first converts it to an integer using this method. Silly.
  • 0
    @-pthread Yeah Java has multiple map implementations in its collections API. An array would work for this, though.

    It's sad to see this kind of code.
  • 3
    What makes me mad is that he is using different functions for months, sometimes calling equals and sometimes equalsIgnoreCase. Just pick a damn one
  • 0
    @AvyChanna

    for some reason thats fucking hilarious!
  • 1
    Why don't you have dark mode in your IDE?
  • 1
    Does java have a switch statement?
    Also, shouldn't System.exit arg be -1 ( or 1 or 2) for error? O thought exit code of 0 means "all is well"? [*NOTE: I haven't used much java]

    I can fully understand not using a feature before introducing it, but in this case, Im not certain that it what's happening... lol
  • 1
    You could also remove all the elses in that function. The ifs will make it fall through "if not", the remaining code is not executed because of the returns. Same thing with the last else...

    There are at least hundreds of things that could be nicer and also teach the students actual programming
  • 0
    >what are arrays
Add Comment