Sunday, November 14, 2010

Side-effects and exceptions have to be completely unexpected to be real fun...

Developers of software for medical applications sometimes show a good sense of humor as the following lines in a highly mission critical Session-Manager show:


bool IsParticipantAttachable(Doctor doc)
{
if (!Session.Attached(doc))
{
Session.Attach(doc); // attach the doctor to the session
return true;
}
else
throw new IllegalSessionStateException("doctor not attachable");
return false;
}


... and now guess what happened to the piece of code that tried to ask the system twice, if a doctor could be attached to a session or not...

No comments:

Post a Comment