What?
LOL comments are part of any compsci's good coding practice. They are essentialy a way of passing the buck to someone else whilst still holding your (perceived)integrity as a programmer because you pointed out how something is crap.
They take the general form:
/* LOL WTF IS THIS, I would do/redo this code in a much nicer way «X» but I can't be fucked to right now because fixable reason «Y» is stopping me. If you are reading this IN TEH FUTURE do something about it for me! */
Example
Here is a realworld PHP example from Ultima
To see the (very simple) webpage this code is used in goto http://www.npm.ac.uk/rsg/projects/l4/
These tend to crop up late on a friday after I have had a couple of pints down the pub, and looking forward to laying on my bed at home staring at the ceiling. This particular example is extra LOL even for me. I had a complete and extra snazy solution in the LOL Comment, but I still just haxd what was there because I knew my edit wouldn't have any negative impact on the rest of the code.
Original code snippet:
function month_days($month){
switch($month){
case 1:
return 31;
break;
case 2:
if(date("L", mktime(0, 0, 0, $month, $day, $year)) == 1)
return 29;
else
return 28;
break;
case 3:
return 31;
break;
case 4:
return 30;
break;
case 5:
return 31;
break;
case 6:
return 30;
break;
case 7:
return 31;
break;
case 8:
return 31;
break;
case 9:
return 30;
break;
case 10:
return 31;
break;
case 11:
return 30;
break;
case 12:
return 31;
break;
default:
return 0;
}
}
This code is clearly shite, and replicating what PHP can do on its own. N.b. there were no comments in these 1500+ lines of code before I got here. The main reason it was so long: some dunce just copy pasted crap and smeared it around everywhere like some cheap whore.
Ultima LOL Comment edit:
/*
Return the number of days in each month (cleaned up from Meteorological station page)
LOL WTF I and whom ever started this madness could just have used:
function month_days($month)
{global $day, $year; return date("t", mktime(0,0,0,$month,$day,"20$year"));}
It amazes me that they used mktime and date to get the leap year anyway!!!!!
even though there is no scope to see $day or $year :((
I might go through and fix this if I get a spare second, if not please clean this up.
*/
function month_days($month){
global $day;
global $year;
switch($month){
case 2:
if(date("L", mktime(0, 0, 0, $month, $day, $year)) == 1)
return 29;
else
return 28;
break;
case 4:
case 6:
case 9:
case 11:
return 30;
break;
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
return 31;
break;
default:
return 0;
}
}
Whoever did the following didn't get the full LOLness of the comment above! I put the actual GOOD function in the comment but left the shit there because I didn't want to take the time to test anything :)
Heh. Why don't they just do:
function dim($month=date("n"),$year=date("Y"))
{
return date("t",mkdate(0,0,0,$month,$year));
}
Or:
function dim($month=date("n"),$year=date("Y"))
{
for($i=31;$i>27;$i--)
if(checkdate($i,$month,$year))
return $i;
}