(I submitted this as a Code SOD but I post it here in case it isn't published)
An ex-coworker of ours took the simplest of tasks and gave them a whole new level of abstraction. Some would call him a terrible programmer, I call him an artistic genius:
private Decimal GetNumStatsPerPage()
{
int factor = 0;
if (this.demoGroupLimit % this.stats.Length == 0) //if stats per page is a multiple of num demos
return (Decimal)this.demoGroupLimit;
else //if not a multiple, return smaller value until it is a multiple of num demos to fit stats per demo per page
{
for( int idx = 1 ; idx < this.demoGroupLimit; idx++ )
{
if ((this.demoGroupLimit - idx) % this.stats.Length == 0)
{
factor = idx;
break;
}
else
continue;
}
return (Decimal)this.demoGroupLimit - factor;
}
}
Note the use of else-continue, a common paradigm among his masterpieces, and the blatant use of Decimal instead of int is so post-modern. Here is the "correct", but totally unaesthetically pleasing version version of the code:
private int GetNumStatsPerPage()
{
return this.demoGroupLimit - this.demoGroupLimit % this.stats.Length;
}