Click here to Skip to main content
15,881,811 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: It's a jungle in there Pin
richard_k15-Aug-11 21:34
richard_k15-Aug-11 21:34 
GeneralMessage Removed Pin
8-Aug-11 4:13
professionalN_tro_P8-Aug-11 4:13 
GeneralRe: Validation fails so lets not use it Pin
fjdiewornncalwe9-Aug-11 3:28
professionalfjdiewornncalwe9-Aug-11 3:28 
GeneralRe: Validation fails so lets not use it Pin
thoiness1-Sep-11 4:55
thoiness1-Sep-11 4:55 
GeneralRe: Validation fails so lets not use it Pin
Shameel9-Aug-11 4:38
professionalShameel9-Aug-11 4:38 
GeneralRe: Validation fails so lets not use it Pin
Chris Berger9-Aug-11 6:18
Chris Berger9-Aug-11 6:18 
GeneralRe: Validation fails so lets not use it Pin
Lutosław11-Aug-11 23:18
Lutosław11-Aug-11 23:18 
GeneralIf not null, return value else return null PinPopular
Keith Barrow7-Aug-11 1:58
professionalKeith Barrow7-Aug-11 1:58 
Only the comment after the method declaration is not mine. Some things have been changed to protect the innocent:

// Why return a "Foo" object type when we can just return a datatable? 
// We do have the type but unpacking it is just *so tiresome*. 
// As is writing a proper DAL or using one of the many free ORMs etc.
public DataTable GetFooByID(int memberID)//MethodID #210
{
  try
  {
    string query = "SELECT DISTINCT * FROM Foo WHERE bar=" + barId;// I hope we don't have little Bobby tables as a member!
    DataTable dt = Utils.ExecuteReader(query);
    //Because we just have too many processor cycles dagnammit:
    if (dt != null)
    {
       return dt;
    }
    else
    {
       return null;
    }
  }
  //Somebody has been reading a book about catch errors on database calls. 
  // Pity they didn't get to the advice about not catching all exceptions 
  catch (Exception ex)
  {
    // Why is it #210? Beacuse the comment next to the method declaration says it is, that's why!
    // No need to deal with pesky stack-traces  with their confusing line numbers or useful additions to the error message!
    throw new Exception("MethodID:= #210, Error:=" + ex.Message);
  }
}


This sort of thing is repeated many times due to the delights of cut-and-paste. We've also cunningly embedded our data access stuff in our object models, no need to look in more than one place! We've not made any attempt at making Data Access easy for ourselves with proxy classes etc.
Mutters....

GeneralRe: If not null, return value else return null Pin
BillW338-Aug-11 13:32
professionalBillW338-Aug-11 13:32 
GeneralRe: If not null, return value else return null Pin
RobCroll9-Aug-11 0:48
RobCroll9-Aug-11 0:48 
GeneralTricking Microsoft and being shamless PinPopular
xavier morera6-Aug-11 5:27
xavier morera6-Aug-11 5:27 
GeneralRe: Tricking Microsoft and being shamless Pin
Shameel7-Aug-11 4:44
professionalShameel7-Aug-11 4:44 
GeneralRe: Tricking Microsoft and being shamless Pin
BillW338-Aug-11 13:23
professionalBillW338-Aug-11 13:23 
GeneralRe: Tricking Microsoft and being shamless Pin
SeattleC++9-Aug-11 4:20
SeattleC++9-Aug-11 4:20 
GeneralRe: Tricking Microsoft and being shamless Pin
Richard X Menezes7-Aug-11 20:36
Richard X Menezes7-Aug-11 20:36 
GeneralRe: Tricking Microsoft and being shamless Pin
BC3Tech9-Aug-11 3:15
BC3Tech9-Aug-11 3:15 
GeneralRe: Tricking Microsoft and being shamless Pin
xavier morera9-Aug-11 3:23
xavier morera9-Aug-11 3:23 
GeneralRe: Tricking Microsoft and being shamless Pin
MehGerbil9-Aug-11 3:27
MehGerbil9-Aug-11 3:27 
GeneralRe: Tricking Microsoft and being shamless Pin
xavier morera9-Aug-11 3:35
xavier morera9-Aug-11 3:35 
GeneralRe: Tricking Microsoft and being shamless Pin
ely_bob9-Aug-11 3:57
professionalely_bob9-Aug-11 3:57 
GeneralRe: Tricking Microsoft and being shamless Pin
BrainiacV9-Aug-11 4:06
BrainiacV9-Aug-11 4:06 
AnswerRe: Tricking Microsoft and being shamless Pin
PivotTableCell9-Aug-11 9:23
PivotTableCell9-Aug-11 9:23 
GeneralRe: Tricking Microsoft and being shamless Pin
xavier morera9-Aug-11 10:19
xavier morera9-Aug-11 10:19 
GeneralRe: Tricking Microsoft and being shamless Pin
ghle9-Aug-11 13:43
ghle9-Aug-11 13:43 
GeneralRe: Tricking Microsoft and being shamless Pin
thoiness1-Sep-11 5:01
thoiness1-Sep-11 5:01 

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.