Is was scanning through some code, trying to determine exactly what it
did (some programmers have a problem with comments, believing that the
only real documentation is source code) when I found a pretty obvious
error:
if (isEmpty(name)) {
ptsReport.setName(name);
}
That is, I thought it was a bug until I found pretty similar code blocks:
if (isEmpty(emplyeeSerial)) {
ptsReport.setSerial(employeeSerial);
}
I decided to check out this infamous isEmpty method and lo and behold:
protected boolean isEmpty(java.lang.String str)
{
return str != null && str.trim().length() != 0;
}
Clear and concise. Self-explanatory code!
P
pink_code
@pink_code
0
Reputation
1
Posts
30
Profile views
0
Followers
0
Following
Best posts made by pink_code
This user hasn't posted anything yet.
Latest posts made by pink_code
-
IsNotReallyEmpty... or what?