Eric Olander - 2005-04-19

Here's a real beauty:

private String getAgentID(TEvent serverEvent)
{
String agentID = serverEvent.AgentID;
if (null != agentID)
if (agentID.length() < 1)
agentID = null;
if (null == agentID)
agentID = getEventField(serverEvent, TServer.AttributeAgentID);
return(agentID);
}

What this really means:

private String getAgentID(TEvent serverEvent)
{
String agentID = serverEvent.AgentID;
if ((null == agentID) || (agentID.length() < 1)) {
agentID = getEventField(serverEvent, TServer.AttributeAgentID);
}
return agentID;
}

Look, I went from 3 if checks to 1 and got rid of a null assignment! And, someone else can actually understand what's going on now. Really, this is just DeMorgan's rule across a couple ifs. I'm thinking it could be possible to write a rule that could detect this trash.

-Eric