Click here to Skip to main content
11,493,687 members (60,777 online)

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.

 
GeneralRe: What was I thinking Pin
David Goebet16-Jan-13 2:40
memberDavid Goebet16-Jan-13 2:40 
GeneralRe: What was I thinking Pin
Matt U.16-Jan-13 2:56
memberMatt U.16-Jan-13 2:56 
GeneralRe: What was I thinking Pin
peterchen16-Jan-13 4:24
memberpeterchen16-Jan-13 4:24 
GeneralRe: What was I thinking Pin
G James16-Jan-13 10:57
memberG James16-Jan-13 10:57 
JokeRe: What was I thinking Pin
Chris Maunder16-Jan-13 19:02
adminChris Maunder16-Jan-13 19:02 
GeneralRe: What was I thinking Pin
33deepak16-Jan-13 19:13
member33deepak16-Jan-13 19:13 
GeneralRe: What was I thinking Pin
Chris Maunder16-Jan-13 19:14
adminChris Maunder16-Jan-13 19:14 
GeneralRe: What was I thinking Pin
James Lonero19-Jan-13 12:08
memberJames Lonero19-Jan-13 12:08 
JokeRe: What was I thinking Pin
Andrew Rissing17-Jan-13 6:48
memberAndrew Rissing17-Jan-13 6:48 
GeneralRe: What was I thinking Pin
Chris Maunder17-Jan-13 10:43
adminChris Maunder17-Jan-13 10:43 
GeneralRe: What was I thinking Pin
Andrew Rissing17-Jan-13 10:55
memberAndrew Rissing17-Jan-13 10:55 
JokeRe: What was I thinking Pin
Jecc23-Jan-13 0:56
memberJecc23-Jan-13 0:56 
GeneralRe: What was I thinking Pin
Nagy Vilmos23-Jan-13 1:33
memberNagy Vilmos23-Jan-13 1:33 
GeneralRe: What was I thinking Pin
Jonathan C Dickinson16-Jan-13 22:21
memberJonathan C Dickinson16-Jan-13 22:21 
G James wrote:
Later they refactored it to this thinking it was an improvement. Smile | :)

return someBooleanVariable == true ? true : false;

That's pretty poor refactoring, it should have been:
interface IBooleanConverter {
 bool BooleanToBoolean(bool value);
}
 
class BooleanConverter : IBooleanConverter {
 public BooleanToBoolean(bool value) {
  return value == true ? true : false;
 }
}
 
interface IBooleanConverterFactory {
 IBooleanConverter CreateBooleanConverterFactory();
}
 
class ConfigurationBooleanConverterFactory : IBooleanConverter {
 public IBooleanConverter CreateBooleanConverter() {
  return (IBooleanConverter)
         Activator.CreateInstance(ConfigurationManager.AppSettings["Types.BooleanConverter"]);
 }
}
 
static class BooleanConverterFactoryFactory {
 public IBooleanConverterFactory CreateBooleanConverterFactory() {
  return (IBooleanConverterFactory)
         Activator.CreateInstance(ConfigurationManager.AppSettings["Types.BooleanConverterFactory"]);
 }
}
 
// ...

return BooleanConverterFactoryFactory.CreateBooleanConverterFactory().CreateBooleanConverter().BooleanToBoolean(someBooleanVariable == true ? true : false);
It is clear that this is more maintainable. There is currently this method in our code-base because some [one] of our developers is so bad that we need to hold his hand through everything:
public static T As<T>(this object obj) {
 return obj as T;
}
Yes guys, an extension method that replicates a keyword.
He who asks a question is a fool for five minutes. He who does not ask a question remains a fool forever. [Chinese Proverb]

Jonathan C Dickinson (C# Software Engineer)

GeneralRe: What was I thinking Pin
Sentenryu16-Jan-13 23:23
memberSentenryu16-Jan-13 23:23 
GeneralRe: What was I thinking Pin
Jonathan C Dickinson16-Jan-13 23:26
memberJonathan C Dickinson16-Jan-13 23:26 
GeneralRe: What was I thinking Pin
Ranjan.D17-Jan-13 12:32
memberRanjan.D17-Jan-13 12:32 
GeneralRe: What was I thinking Pin
Rob Grainger1-Feb-13 4:21
memberRob Grainger1-Feb-13 4:21 
GeneralRe: What was I thinking Pin
Tomz_KV17-Jan-13 3:58
memberTomz_KV17-Jan-13 3:58 
RantHappy new year... kind of... Pin
hoernchenmeister15-Jan-13 23:03
memberhoernchenmeister15-Jan-13 23:03 
GeneralRe: Happy new year... kind of... Pin
PIEBALDconsult16-Jan-13 4:50
memberPIEBALDconsult16-Jan-13 4:50 
GeneralRe: Happy new year... kind of... Pin
hoernchenmeister16-Jan-13 6:06
memberhoernchenmeister16-Jan-13 6:06 
GeneralRe: Happy new year... kind of... Pin
Matthys Terblanche16-Jan-13 22:08
memberMatthys Terblanche16-Jan-13 22:08 
GeneralRe: Happy new year... kind of... Pin
Gary Huck17-Jan-13 4:41
memberGary Huck17-Jan-13 4:41 
GeneralRe: Happy new year... kind of... Pin
Dave Kreskowiak17-Jan-13 6:26
mvpDave Kreskowiak17-Jan-13 6:26 
GeneralRe: Happy new year... kind of... Pin
Jörgen Andersson17-Jan-13 10:04
memberJörgen Andersson17-Jan-13 10:04 
GeneralRe: Happy new year... kind of... Pin
peterchen28-Jan-13 23:05
memberpeterchen28-Jan-13 23:05 
GeneralRe: Happy new year... kind of... Pin
hoernchenmeister28-Jan-13 23:49
memberhoernchenmeister28-Jan-13 23:49 
JokeRe: Happy new year... kind of... Pin
VUnreal8-Feb-13 11:27
memberVUnreal8-Feb-13 11:27 
GeneralJust got an error from VS2012 Pin
Brisingr Aerowing15-Jan-13 9:48
memberBrisingr Aerowing15-Jan-13 9:48 
GeneralGetting it wrong badly Pin
PIEBALDconsult9-Jan-13 15:12
memberPIEBALDconsult9-Jan-13 15:12 
GeneralRe: Getting it wrong badly Pin
Sentenryu10-Jan-13 7:31
memberSentenryu10-Jan-13 7:31 
GeneralRe: Getting it wrong badly Pin
PIEBALDconsult10-Jan-13 8:42
memberPIEBALDconsult10-Jan-13 8:42 
GeneralRe: Getting it wrong badly Pin
Sentenryu10-Jan-13 23:31
memberSentenryu10-Jan-13 23:31 
GeneralRe: Getting it wrong badly Pin
AspDotNetDev10-Jan-13 8:37
protectorAspDotNetDev10-Jan-13 8:37 
GeneralRe: Getting it wrong badly Pin
PIEBALDconsult10-Jan-13 8:52
memberPIEBALDconsult10-Jan-13 8:52 
GeneralRe: Getting it wrong badly Pin
AspDotNetDev10-Jan-13 9:11
protectorAspDotNetDev10-Jan-13 9:11 
GeneralFacepalm Moment Pin
Zac Greve7-Jan-13 9:47
memberZac Greve7-Jan-13 9:47 
GeneralRe: Facepalm Moment Pin
PJ Arends7-Jan-13 10:03
memberPJ Arends7-Jan-13 10:03 
GeneralRe: Facepalm Moment Pin
Zac Greve7-Jan-13 10:06
memberZac Greve7-Jan-13 10:06 
GeneralRe: Facepalm Moment Pin
peterchen7-Jan-13 11:03
memberpeterchen7-Jan-13 11:03 
GeneralRe: Facepalm Moment Pin
Zac Greve7-Jan-13 11:12
memberZac Greve7-Jan-13 11:12 
GeneralRe: Facepalm Moment Pin
Dave Kreskowiak7-Jan-13 10:15
mvpDave Kreskowiak7-Jan-13 10:15 
GeneralRe: Facepalm Moment Pin
Zac Greve7-Jan-13 10:30
memberZac Greve7-Jan-13 10:30 
GeneralRe: Facepalm Moment Pin
BobJanova8-Jan-13 0:29
memberBobJanova8-Jan-13 0:29 
GeneralRe: Facepalm Moment Pin
PIEBALDconsult7-Jan-13 10:17
memberPIEBALDconsult7-Jan-13 10:17 
GeneralRe: Facepalm Moment Pin
lewax007-Jan-13 11:52
memberlewax007-Jan-13 11:52 
GeneralRe: Facepalm Moment Pin
Jörgen Andersson7-Jan-13 11:05
memberJörgen Andersson7-Jan-13 11:05 
GeneralRe: Facepalm Moment Pin
Pete O'Hanlon7-Jan-13 11:17
protectorPete O'Hanlon7-Jan-13 11:17 
GeneralRe: Facepalm Moment Pin
Zac Greve7-Jan-13 11:20
memberZac Greve7-Jan-13 11:20 

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

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web01 | 2.8.150520.1 | Last Updated 29 May 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid