5 ms·
I'm apparently too opinionated to survive long in insane environments, but I did intern for a company that, in Java, did a couple of really disturbing things:
by gchpaco 17y ago
I'm apparently too opinionated to survive long in insane environments,
but I did intern for a company that, in Java, did a couple of really
disturbing things:
1. Every Java exception that can possibly be thrown from a method must
be caught, logged, appended to a new Java exception, and re-thrown.
Fully 2/3rds of the code base was this sort of make-work.
2. They followed the traditional naïve model of distributing a system:
break it into functional units, and put those on different machines.
Win! Well, except that now every single query needs to talk to six
machines, all of which need to be up.
3. Their system, running RMI, was of course implicitly multithreaded,
because that's how RMI works. I didn't see in the codebase any real
attention paid to this, so I asked about it and the project lead said
"the two guys who know threading aren't in at the moment, but we'll
schedule a meeting Tuesday when they make it in" on a team of thirty.
Needless to say, the resulting system was a complete mess...
- kaitnieks 17y agoI haven't programmed Java besides some tiny things so I'm curious about #1. Suppose someone wanted to log all exceptions. How would you go about it in Java?
- gchpaco 17y agoWell, you certainly don't need to log and rethrow them at every call site, because Java exceptions contain a stack trace. Sometimes rethrowing is necessary, because of Java checked exceptions. Sometimes exceptions are benign. The best rule I've seen is the follows: never catch an exception if you can't handle it (either by dying, wrapping it to work around Java lameness, etc.).
- kaitnieks 17y agoLogging all unhandled exceptions can be an additional measure for ensuring quality. You have coded defensively, you have done a careful testing but it still crashes. It happens. I do agree with your point that logging exceptions that might be handled upwards the call stack is silly and probably makes the whole log useless.