Was recently porting some old code and came across this beautiful bit of coding
if(BlueJunkAPI.needsAttention(msgId))
{
switch(msgId)
{
case BlueJunkAPI.ATTENTIONREQUIRED:
socketError = handleAttentionReq(messageOut, messageIn);
}
}
public static boolean needsAttention(int messageId)
{
switch(messageId)
{
case ATTENTIONREQUIRED:
return(true);
default:
return(false);
}
}
Yes, ladies and gentlemen, that's 18 lines of code, including an IF statement and not one, but two SWITCHes to compare two integers and then make a function call