# Can I submit invalid and funny code on Code Review?

I found some cool functions in some really old code that I have to maintain. I think it could be useful to review them. For fun, and to understand what they're supposed to do.

Finding what it is supposed to do is like a mix between a riddle and a code review.

Here is an example:

This function check a date. Every morning the boss uses it. Today he found that writing his password in the date field gave him better results than using the date.

function CheckDate ($date,$Return='Error')
{
$longdate=strlen($date);
// longdate !=8 ?
$pos1slash=strpos($date,"/");
$pos2slash=strrpos($date,"/");
$datewhslash=ereg_replace("/",'',$date);

$dd=substr($datewhslash,0,2);
settype($dd,"integer");$mm=substr($datewhslash,2,2); settype($mm,"integer");
$yy=substr($datewhslash,4,2);
settype($yy,"integer"); If(60<$yy && $yy<99) {$yyyy='19'.$yy; } Else {$yyyy='20'.$yy; } settype($yyyy,"integer");

If(!(0<$dd &&$dd<=31) || !(0<$mm &&$mm<=12) || !(0<=$yy &&$yy<=99) ||$pos1slash!=2 ||$pos2slash!=5)
{
$date=$Return;
}
Else
{
If($dd>($nday=getNbDay($mm,$yyyy)))
{
$dd=$nday;
If(0<$yy &&$yy<10)
{
$date=$dd.'/'.$mm.'/0'.$yy;
}
Else
{
$date=$dd.'/'.$mm.'/'.$yy;
}
}
}
return \$date;
}


As a reviewee, it's your responsibility to tell reviewers what your code does, and the code is expected to be working as intended - so invalid code isn't going to fly.

Valid and funny code can be (and has been) reviewed - we have a tag, and every once in a while there's a piece of code written in some esoteric language.

If you can explain what that old code does (it works as intended, right?), present it to reviewers (as you would with any other piece of code), and it will be reviewed and possibly improved.

But no, we don't do "what does this code do?" riddles on this site, it would open the door to a type of question we're not interested in answering, because it's not reviewing/improving code.

Code Review is not The Daily WTF and I think it would be a shame to try to move it in that direction.

First, I think the kind of post you propose to make risks coming across as mean-spirited, and sending a negative message to potential posters. We would like beginner programmers to feel safe that they can post their code here without getting ridiculed. This aim conflicts with your aim of amusing yourself by laughing at bad code, and given this conflict I think we are better off concentrating on being friendly to beginners.

Second, I don't want to spend time and effort reviewing code unless I have at least some hope that someone is going to take action to improve the code based on my review. This is just my opinion, and no doubt other users of the site will disagree. But I think it's vital to be upfront about the situation — I'd feel cheated if I wrote an answer only to later discover that that the poster was not interested in improving the code. At least if it is explained in the post, I can downvote and move on.

• I didn't want Reviewer to wast time. Every code Would have been explain before end . With is possible input , his expected output. And what the name and the 'Commentaire' Tell us about what it should do. But you are right, i was trying to bring you some of the fun i find every day rewriting this old code, the way daily WTF does. – Drag and Drop Oct 17 '16 at 10:11
• Related meta post: Posting Code Review questions on code shaming sites – 200_success Oct 17 '16 at 20:55