Amazon Black Hat coding question
I’m at Black Hat, hanging out at the Amazon booth with my colleagues, and quite amazed at the stir created by the coding question I put up on the board.
For those of you that haven’t had a chance to see the code, or need more time to figure out what’s wrong, I’m posting the code here. Sadly, no prizes for those of you who aren’t able to come to the booth, and I won’t be accepting posts commenting on the code until after the conference is over.
Consider it a theoretical exercise in code review – how would you handle this Java code arriving in front of you at a code review?
public static boolean isDifferent(
final MyBean oldBean,
final MyBean newBean)
oldBean != newBean &&
oldBean != null &&
Post your comments, and after the conference is over, I’ll open them up.
For those of you that think in C++ instead of Java (and there were many at the conference), here’s a version in that language:
static bool isDifferent(
const someClass const * oldObject,
const someClass const * newObject)
oldObject != newObject &&
oldObject != NULL &&
There are no ‘cheat’ issues – code not present in the sample is assumed to be perfect.