Hacker News new | ask | show | jobs
by Luyt 5533 days ago
That reminds me I once came along code written like this:

  function MakePrintable(nr as Int) 
  {
    Str as string
    if nr=1 then Str="1"
    if nr=2 then Str="2"
    if nr=3 then Str="3"
    ...
    if nr=27 then Str="27"
    if nr=28 then Str="28"
    if nr=29 then Str="29"
    return Str
  }
This code worked in the program it was used in (it Got Things Done), but in a dumb way (lazy? ignorant?).

I admit this is a rather extreme example, but it provokes the universal feeling when you look at gravely suboptimal code: "What did the programmer think when he wrote this? Didn't he know that ...., it's so obvious!"

1 comments

Buffer Overflow Exploit Prevention?