Showing posts with label Code Errors. Show all posts
Showing posts with label Code Errors. Show all posts

Saturday, July 9, 2011

You “Try”… and what do you “Catch”… A TryCatchException!

This is posted without much ranting, hoping that the humour and the pun is evident and the code snippet self-explanatory. This code was written by someone who apparently regarded the try{} catch {} construct itself error prone and decided to catch a TryCatchException.

try
{
    //Some Magic Code here
}
catch (Exception ex)
{
    var exceptionEntry = new TryCatchException("Method error", ex);
    throw exceptionEntry;
}

I have to admit this one is an original. I particularly like the additional detail (that is completely useless) “Method error”


Code Responsibly.

Tuesday, June 28, 2011

When 55 arguments are just about enough!!

In Robert Martin’s “a.k.a Uncle Bob” Clean Code book, he classifies Niladic functions (that have Zero arguments) as the best well behaved functions that are ideal to write and deal with; Monadic and Dyadic functions (that have 1 and 2 arguments respectively) comes as a second best. Anything Polyadic (with more than three arguments) is just pure evil and requires justification.

I wonder though how he would feel about a function with 55 arguments!! The following is just the signature of this function

(Int32,Int32,String,Int32,Int32,String,Int32,Int32,String,Int32 ,String,String,String,Int32,Int32,String,Int32,String,Int32,String ,Int32,String,Int32,Int32,Int32,DateTime,DateTime,String,String ,DateTime,DateTime,String,String,DateTime,DateTime,String,String ,String,String,String,Decimal,Decimal,Decimal,Decimal,Decimal,Decimal ,Int32,Int32,Int32,Int32,Int32,Int32,String,Int32,String)

If I were to meet that developer who wrote that function, I would simply ask, WTF were you thinking!?

May we survive the coding horrors yet another day!

Stay#

Friday, June 4, 2010

The Daily WTF

Greetings All Code Monkeys...

For those of us who have been subjected to unforgettable code atrocities, or for those who would like to seek solace in other people's horrendous coding errors (to feel better about their own!) - yes we all are red handed when it comes to writing code that should never have seen the light of day.

Check the The Daily WTF gives you the fix.I love that web site.