A couple of years ago I was working with some friends on a personal Java project. We used to meet every Saturday to review what we had done before building the entire system. Let me introduce you to my friends: Susan Obstinate and Mark Nowsitall (weird last names, aren't they?).
"I've spent the entire week writing this code, but it's ready now," said Susan with an embittered tone.
"Let me see how you handled that," replied Mark suspiciously. Though they didn't seem to be, they were a couple.
So Susan proudly showed us her piece of code:
// some nasty code was here (censored for respect of the reader)
public String getUglyUrl(long total) {
String url = "http://localhost/app/someservice?code=";
for(long i = 0; i < total; i++) {
url += someTrickyMath(i);
}
return url;
}
public String someTrickyMath(long i) {
// (censored)
}
"We can use an int
object type instead of long
for the loop in your getUglyUrl
method," instantly affirmed Mark...