Click here to Skip to main content
15,884,986 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Range Checking Pin
richard_k5-Nov-10 19:24
richard_k5-Nov-10 19:24 
GeneralRe: Range Checking Pin
Chris Meech1-Nov-10 5:03
Chris Meech1-Nov-10 5:03 
GeneralRe: Range Checking Pin
AspDotNetDev1-Nov-10 6:22
protectorAspDotNetDev1-Nov-10 6:22 
GeneralRe: Range Checking Pin
fjdiewornncalwe2-Nov-10 1:35
professionalfjdiewornncalwe2-Nov-10 1:35 
GeneralUgly, ugly, ugly! Pin
jamie55031-Oct-10 12:24
jamie55031-Oct-10 12:24 
GeneralRe: Ugly, ugly, ugly! Pin
AspDotNetDev31-Oct-10 12:29
protectorAspDotNetDev31-Oct-10 12:29 
GeneralRe: Ugly, ugly, ugly! Pin
Lutosław31-Oct-10 14:33
Lutosław31-Oct-10 14:33 
GeneralWhen the CEO becomes a developer I Pin
imagiro29-Oct-10 23:31
imagiro29-Oct-10 23:31 
A company hired me for cleaning up the PHP-code the CEO created. The whole code reads like a how-not-to of programming, so I decided to post some of the gems here. This is the first one (I preserved all the formatting):

MyCart::IsContentvalid() checks items in the cart against a database. Each call does 3 queries (per item!) of tables with around 500.000 entries. Note also the clever use of quotation marks.
PHP
      if(MyCart::IsContentvalid()==1)
  {

  Helper::Redirect("confirmation.php");
  }

  if(MyCart::IsContentvalid()==2)
  {

$this->setErrorMsg("$curlang[error_msg1]");
  }

  if(MyCart::IsContentvalid()==-12)
  {

$this->setErrorMsg("These items can not be sold.");
  }

  if(MyCart::IsContentvalid()==15)
  {

$this->setErrorMsg("Your account doesn't allow you to buy these items.");
  }


else

  {

    //Helper::Redirect("confirmation.php");
    $this->setErrorMsg("$lang[error_msg2]");
  }

Oh, and the use of else is only for advanced programmers:
PHP
if ($result == 1)
{
  // do something here
}
if ($result != 1)
{
  // do something else here
}

More will come soon!
GeneralRe: When the CEO becomes a developer I Pin
richard_k5-Nov-10 19:27
richard_k5-Nov-10 19:27 
GeneralWell it made me laugh anyway Pin
musefan29-Oct-10 6:33
musefan29-Oct-10 6:33 
GeneralRe: Well it made me laugh anyway Pin
Chris Meech29-Oct-10 6:51
Chris Meech29-Oct-10 6:51 
GeneralRe: Well it made me laugh anyway Pin
Jeroen De Dauw29-Oct-10 10:19
Jeroen De Dauw29-Oct-10 10:19 
GeneralRe: Well it made me laugh anyway PinPopular
Lutosław31-Oct-10 14:26
Lutosław31-Oct-10 14:26 
GeneralRe: Well it made me laugh anyway Pin
musefan2-Nov-10 23:45
musefan2-Nov-10 23:45 
GeneralIt's not the most horrible code but it is pointless Pin
Andy Brummer28-Oct-10 10:36
sitebuilderAndy Brummer28-Oct-10 10:36 
GeneralRe: It's not the most horrible code but it is pointless Pin
Pete O'Hanlon28-Oct-10 12:31
mvePete O'Hanlon28-Oct-10 12:31 
GeneralRe: It's not the most horrible code but it is pointless Pin
Andy Brummer29-Oct-10 1:38
sitebuilderAndy Brummer29-Oct-10 1:38 
GeneralRe: It's not the most horrible code but it is pointless Pin
fjdiewornncalwe28-Oct-10 13:29
professionalfjdiewornncalwe28-Oct-10 13:29 
GeneralRe: It's not the most horrible code but it is pointless Pin
Al_Brown29-Oct-10 0:49
Al_Brown29-Oct-10 0:49 
GeneralRe: It's not the most horrible code but it is pointless Pin
fjdiewornncalwe29-Oct-10 4:07
professionalfjdiewornncalwe29-Oct-10 4:07 
GeneralRe: It's not the most horrible code but it is pointless Pin
QuiJohn29-Oct-10 4:14
QuiJohn29-Oct-10 4:14 
GeneralRe: It's not the most horrible code but it is pointless Pin
richard_k5-Nov-10 19:31
richard_k5-Nov-10 19:31 
GeneralIt's the small things that matter. Pin
puromtec127-Oct-10 17:24
puromtec127-Oct-10 17:24 
GeneralRe: It's the small things that matter. Pin
Stephen Hewitt27-Oct-10 19:07
Stephen Hewitt27-Oct-10 19:07 
GeneralRe: It's the small things that matter. Pin
OriginalGriff27-Oct-10 21:41
mveOriginalGriff27-Oct-10 21:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.