Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
necrobobsledder
Mar 21, 2005
Lay down your soul to the gods rock 'n roll
Nap Ghost
I'm having to do some flow control based upon exceptions that come back in Java and am wondering if there's anything that can do the following more cleanly:

code:
Class c;
try {
  try {
    c = Class.forName(someclasspathA);
  } catch(ClassNotFoundException e) {
    c = Class.forName(someclasspathB);
  }
} catch (ClassNotFoundException e) {
  // no suitable classpath found, throw exception
}
I suppose trying to do a for loop like the following might be worth a shot:

code:
Class c;
for (String className : listOfClassNames) {
  if (c != null)
    break;
  try {
    c = Class.forName(className);
  } catch (ClassNotFoundException e) {
    // doesn't matter, blah
  }
}
if (c == null)
 throw new ExceptionOfDoom();
I'm trying to dynamically load classes at runtime and can't write a classloader :(

Adbot
ADBOT LOVES YOU

necrobobsledder
Mar 21, 2005
Lay down your soul to the gods rock 'n roll
Nap Ghost

tef posted:

A major problem with comments is that they frequently outlast the code they were written for. Code gets changed, and comments lag behind. Comments in the wild are often misleading, rather than helpful.
This varies from codebase to codebase, but I'm of the opinion that if you write some decent tests and treat them as holy and sacrosanct, then whatever you write to fulfill / appease those tests should serve better than documentation unless it comes to documenting method calls in an API (ie. what Javadocs or Doxygen docs are good for and that's about it). Not that I'm saying TDD is quite correct, but that's just what unit tests are good for. Traditionally, every time I hit a bug, I write a test case for it so that regressions don't happen, and mark in the block that hits it with // HACK as a warning sign. This way, the only regression bugs I've hit though, admittedly, are documentation bugs (ironically, from auto-generating documentation over the manually written stuff and realizing my annotations and references are outdated from when I was hacking at 3 am).

Furthermore, deleting comments when they're outdated shouldn't be considered a faux pas when you're using version control - you can always get it back. Dead code and dead documentation should be pruned and weeded like your garden and lawn. It's healthy.

necrobobsledder
Mar 21, 2005
Lay down your soul to the gods rock 'n roll
Nap Ghost
There's got to be some middle ground between using something like rdtsc and hoping your rtc syscall call uses a hardware RTC in some manner. Last I remember when I looked at sub-microsecond benchmarking seriously (literally 10 years ago), the only way to get a fairly accurate picture of function calls was to use both highly instrumented userland software like from Rational software and to utilize a kernel that uses event-based clocking for its multi-process management like HP/UX. The inaccuracy of timers was pretty much inversely proportional to the length of the function run indicating probably overhead of timing being at the minimum constant and possibly even higher as the measurement interval gets shorter.

necrobobsledder
Mar 21, 2005
Lay down your soul to the gods rock 'n roll
Nap Ghost

Zhentar posted:

"I'm getting an 'Out Of Memory' error, does that mean I need to upgrade my RAM? I thought I already had plenty!". The considerable majority of programmers, even among the good ones, have very little understanding of the systems behind making their high level language code work.
I've been having to tell senior software engineers with 12+ years of experience in Java about why running out of PermGen doesn't mean that there's something wrong with your memory mappings under VMware. But these types of folks also tend to have deficiencies somewhere in their general professional knowledge area because they do not have the instinct to look beyond their own domain. The best will not be comfortable knowing just their own piece, ever.

Blinkz0rz posted:

My question is, what are the best way to begin implementing development best practices in this environment?
Kinda tough if you're doing it on your own more or less, but you'll need to be able to demonstrate one or more of the following with various "best practices":

1. superior performance / output (profilers caught that we were spending 30% of our time writing log files)
2. successful risk management (this test caught x, y, z before it went into production, knowing the build broke identified Bob breaks builds literally every commit)
3. easier manageability (one command to build something, stamp a release, and know it'll work = immense power and a sigh of relief for managers)

You can't really implement change without the right culture for accepting it though. You don't want to be the dude at RIAA insisting that they have to work with digital media.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply