Mark Bowytz

Besides contributing at @TheDailyWTF, I write DevDisasters for Visual Studio Magazine, and involved in various side projects including child rearing and marriage.

Dec 2008

What the Ad? - Executives So Cra-zay

by in Feature Articles on

Here at work, we use a Lanier Multi-Function Printer/Scanner/Fax/Toaster the size of a small car that does tons of things and does them pretty well. However, back in 1981, Lanier was in the business of selling systems, and if you think that their EZ-1 was simply a word processor, you'd best think again.


The 8 Report and Other Gems

by in CodeSOD on

Peter Korsten used to work with a truly brilliant and exceptional individual. Before leaving for greener pastures and better pay, one of his former co-workers left an indelible mark on their system via his rather unique approach to programming.

The Great 8 Report

One of these artifacts was the "8" report which consisted of the following SQL query: 


Your Glitch Has Been Reserved

by in Feature Articles on

Photo credit: 'Rob React' at Flickr When Nick Martin arrived at work at 8:30am, it seemed like he was in for a good day. Warm bagel and coffee in hand, he strolled into the IT office ready to fire up his email and maybe do a little recreational surfing before jumping into a day's worth of work. However, this was not meant to be as he was greeted by a support issue already in progress. And by "greeted", I mean "a dreary mess of a woman in a pinstripe suit was storming his way". It was Darlene, a manager from the university's financial department and conveniently, he was the only warm body in the office.

"Do you NOTICE any DIFFERENCE between these two printouts, Nick?"


Validating a Date with a Sledgehammer

by in CodeSOD on

I think that it goes without saying that handling freeform user input, no matter the programming language, can be a tricky endeavor.  Having to work with code like today's SOD makes me appreciate the pain felt by this bit of code Catherine Palmer inherited. 

Now, I won't say that this function is necessarily terrible code, but when you consider that the field that code is intended to handle demands (in big red text) the entry of a date in a specific format (DD/MM/YYYY to be exact) and that it's meant to prevent a user from entering a date in the future, it'll leave you wondering why "TONY B" chose this exact plan of attack.

<script language="JavaScript">
<!--
function validate_futuredate(userdate)
//--- THIS DATE VALIDATION WAS DESIGNED BY ----//
//---    TONY B------- ON 02/05/2000 -----//
{
//---- get user date ---------------//
dday = userdate.value.substring(0,2)
mmnth = userdate.value.substring(3,5)
yyear = userdate.value.substring(6,10)

//--- get system date ---------------
curdate = new Date()
curyear = curdate.getFullYear()
curday = curdate.getDate()
curmonth = curdate.getMonth()
curmonth ++
//--- add one dayto curmonth as function produces zero for january ---//

strday=String(curday).length
strmonth=String(curmonth).length
//--- check that system day and month length greater 1 if not insert zero ---//
if (strday == 1)
        {
      curday = "0" + String(curday)
      }
     
  if (strmonth == 1)
        {
      curmonth = "0" + String(curmonth)
      }  
//--- create todays date to write back to input box on user input error ---//    
ddate1 = curday + "/" + curmonth + "/" + String(curyear)

//--- get length and value of user input date ---//
posit = userdate.value
poslen = posit.length
//--- check date contains 10 characters ---//
  if(poslen != 10)
    {
    alert("date contains wrong number of characters default value set")
    userdate.value = ddate1
    userdate.focus()
    return (false)
    }
//--- get first character of date make sure its less than 4 ---//
posit0 = userdate.value.charAt(0)
if (posit0 < "0" || posit0 > "3")
    {
    alert("date contains invalid DAY default value set")
    userdate.value = ddate1
    userdate.focus()
    return (false)
    }
posit1 = userdate.value.charAt(1)

if (posit1 < "0" || posit1 > "9")
    {
    alert("date contains invalid DAY default value set")
    userdate.value = ddate1
    userdate.focus()
    return (false)
    }
   
  if (posit1 == "0" && posit0 == "0")
    {
    alert("date contains invalid DAY default value set")
    userdate.value = ddate1
    userdate.focus()
    return (false)
    }
   
  if (posit0 == "3" && posit1 > "1")
    {
    alert("date contains invalid DAY default value set")
    userdate.value = ddate1
    userdate.focus()
    return (false)
    }
   
posit5 = userdate.value.charAt(5)
posit2 = userdate.value.charAt(2)
if (posit2 != "/" || posit5 != "/")
    {
    alert("date missing forward / mark default value set")
    userdate.value = ddate1
    userdate.focus()
    return (false)
    }

posit3 = userdate.value.charAt(3)
if (posit3 < "0" || posit3 > "1")
    {
    alert("date contains invalid MONTH default value set")
    userdate.value = ddate1
    userdate.focus()
    return (false)
    }
posit4 = userdate.value.charAt(4)
if (posit4 < "0" || posit4 > "9")
    {
    alert("date contains invalid MONTH default value set")
    userdate.value = ddate1
    userdate.focus()
    return (false)
    }
if (posit4 == "0" && posit3 == "0")
    {
    alert("date contains invalid MONTH default value set")
    userdate.value = ddate1
    userdate.focus()
    return (false)
    }

if (posit3 == "1" && posit4 > "2")
    {
    alert("date contains invalid MONTH default value set")
    userdate.value = ddate1
    userdate.focus()
    return (false)
    }
posit6 = userdate.value.charAt(6)
if (posit6 != "2")
{
    alert("date contains invalid YEAR default value set")
    userdate.value = ddate1
    userdate.focus()
    return (false)
    }
posit7 = userdate.value.charAt(7)

if (posit7 != "0")
{
    alert("date contains invalid YEAR default value set")
    userdate.value = ddate1
    userdate.focus()
    return (false)
    }

posit8 = userdate.value.charAt(8)
posit9 = userdate.value.charAt(9)

if (posit8 < "0" || posit8 > "9" || posit9 < "0" || posit9 > "9")
    {
    alert("date contains invalid YEAR at position9/10 default value set")
    userdate.value = ddate1
    userdate.focus()
    return (false)
    }

if (dday == "31" && (mmnth == "04" || mmnth == "06" || mmnth == "09" || mmnth == "11"))
  {
alert("wrong number of days in specified MONTH default value set")
userdate.value = ddate1
userdate.focus()
    return (false)
    }
   
  if (dday > "28" && mmnth == "02" )
  {
alert("wrong number of days in specified MONTH default value set")
userdate.value = ddate1
userdate.focus()
    return (false)
    }
    if (yyear > curyear)
    {
    alert("future dates are not allowed")
    userdate.value =ddate1
    userdate.focus()
    return(false)
    }
else if (yyear == curyear)
{
    if(mmnth > curmonth)
    {
        alert("future dates are not allowed")
            userdate.value =ddate1
            userdate.focus()
        return(false)
    }
   
    else if (mmnth == curmonth)
    {
      if (dday > curday)
      {
      alert("future dates are not allowed")
          userdate.value =ddate1
          userdate.focus()
        return(false)
      }
    }
}
 
return(true)
}
//-->
</script>
 

What the Ad? - Portability, 1980's Style

by in Feature Articles on

If early 1980's marketing is to be believed, then the guy hauling around dead trees in a faux leather case is doing it completely wrong.


Java Takes Down the Network

by in Feature Articles on

Photo credit: 'Csaba_Bajko' at Flickr "Alright! 11:02 a.m...Another five bucks for me!"

Once again, Ricky Fine had hit it big in the network technician over/under betting pool for predicting the time of the daily network outage. It occurred around 11am, every day, but not precisely. The network would pulse on and off around 60 cycles per minute, but again, not exactly.


What the Ad? - Big Promises

by in Feature Articles on

I'm not saying that some advertising is prone to exaggeration, but sometimes, on occasion, the truth might be stretched at least a little bit.  Here are a few ads that I came across that I thought may be overstating their abilities just a little bit.

If "THE LAST ONE" is to be believed, any idiot can now write completely bug-free programs in plain English. All for only $600? More proof that my college education was only worth the certificate of attendance that I got out of it.


The Sky's the Limit!

by in CodeSOD on

This code was sent to John W. by the support staff of one of the larger software vendors with the stated purpose of determining how much memory a program could use on one of the corporation's Unix servers. 

#include <stdio.h>
#include <malloc.h>
 
int
 
main ()
{
float f;
char *p;
 
   while (1)
   {
      p = malloc(102400);
      if (!p)
         {
          printf ("malloc returned NULL\n");
          exit(1);
         }
  
      f += 102400;
      printf ("%g\n", f);
      printf ("%g %f %f MB\n", f, f, f/1024000);
  
   }
}

The Great Excel Spreadsheet

by in Feature Articles on

Photo Credit: 'pit-yacker' at FlickrFresh out of school, Maxim was able to score himself a pretty sweet entry level position in a small private bank. Rather than being responsible for maintaining the company's static phone book on the corporate intranet or some other stereotypical entry level thing, he was placed in the understaffed Publications department to do some surprisingly heavy impacting IT work.

The department's job was to produce and distribute various financial reports including the most important one of all - the Recommendation List. This list was considered mission critical for the bank as it contained the official recommendations of what stocks and bonds to buy or sell and was sent out to managers and customers alike. A bad recommendation could make or break the financial managers, not to mention the customers whom invested their money with the bank, who made decisions based on this information.