Click here to Skip to main content

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, embarrasing 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.

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page  Show 
GeneralRe: Try/catch block...memberGary R. Wheeler21 Nov '12 - 4:26 
Sigh.
public string ReadFile(string filename)
{
  string contents = null;
  try
  {
    contents = File.ReadAllText(filename);
  }
  catch
  {
    contents = File.ReadAllText(filename);
  }
  finally
  {
    contents = File.ReadAllText(filename);
  }
  return contents;
}
Okay. Everybody happy now?
Software Zen: delete this;

GeneralRe: Try/catch block...memberPhilLenoir21 Nov '12 - 6:36 
Quitter - use recursion!
public string ReadFile(string filename)
{
     try
     {
          return File.ReadAllText(filename);
     }
     catch
     {
          return ReadFile(filename);
     }
}
Life is like a s**t sandwich; the more bread you have, the less s**t you eat.

GeneralRe: Try/catch block...memberZac Greve27 Nov '12 - 8:24 

 
brisingr@gryphon-pc$ cpmsg --process --msg "4433493" --forum "The Weird and The Wonderful" --code "Process"
 
ERROR: StackOverflowException was encountered.
 
brisingr@gryphon-pc$|
 

Bob Dole
The internet is a great way to get on the net.

D'Oh! | :doh: 2.0.82.7292 SP6a

GeneralRe: Try/catch block...memberMember 771191721 Nov '12 - 9:12 
Maybe we need a more flippant programming language, for those of us who think like this:
 
try
{
   // something
}
ifatfirstyoudontsucceed
{
    // try again
}
thirdtimelucky
{
    // and again
}
giveup // synonym for catch
{
    // error handling
}
finally
{
    // tidying up
}

GeneralRe: Try/catch block...memberkakan28 Nov '12 - 0:46 
Bernhard Hiller wrote:
three is the magic number

 
It sure is!
Monty Python :
 
First shalt thou take out the Holy Pin.
Then, shalt thou count to three, no more, no less.
Three shalt be the number thou shalt count, and the number of the counting shall be three.
Four shalt thou not count, nor either count thou two, excepting that thou then proceed to three.
Five is right out.
Once the number three, being the third number, be reached, then lobbest thou thy Holy Hand Grenade of Antioch towards thy foe, who, being naughty in my sight, shall snuff it."
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson

GeneralRe: Try/catch block...memberPIEBALDconsult20 Nov '12 - 13:30 
It lacks a while.
GeneralRe: Try/catch block...memberjasperp20 Nov '12 - 20:56 
I like it. Another opportunity to bill the client.
GeneralRe: Try/catch block...memberspencepk21 Nov '12 - 4:03 
Huh... why bother?
GeneralRe: Try/catch block...memberProgramFOX21 Nov '12 - 4:10 
When I was programming that, I thought: "It's in a catch block, then it can't throw an error!" Dead | X|
ProgramFOX

GeneralRe: Try/catch block...memberRafagaX21 Nov '12 - 4:28 
Mmmm... you seem determined to read that file, is it important?
CEO at:
- Rafaga Systems
- Para Facturas
- Modern Components
for the moment...

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


Advertise | Privacy | Mobile
Web01 | 2.6.130523.1 | Last Updated 24 May 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid