Click here to Skip to main content
15,888,802 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: Wasted space Pin
Dan Neely19-Oct-09 10:31
Dan Neely19-Oct-09 10:31 
GeneralRe: Wasted space Pin
David Skelly19-Oct-09 22:21
David Skelly19-Oct-09 22:21 
GeneralRe: Wasted space Pin
Richard MacCutchan19-Oct-09 10:50
mveRichard MacCutchan19-Oct-09 10:50 
GeneralRe: Wasted space Pin
OriginalGriff19-Oct-09 22:16
mveOriginalGriff19-Oct-09 22:16 
GeneralRe: Wasted space Pin
Richard MacCutchan19-Oct-09 23:56
mveRichard MacCutchan19-Oct-09 23:56 
GeneralRe: Wasted space Pin
David Skelly19-Oct-09 22:18
David Skelly19-Oct-09 22:18 
GeneralRe: Wasted space Pin
Machaira15-Oct-09 2:31
Machaira15-Oct-09 2:31 
GeneralRe: Wasted space Pin
dojohansen15-Oct-09 0:50
dojohansen15-Oct-09 0:50 
ANY code that is repetitive is almost always an indication that it's bad code. The main exception to this is if the code is generated.

If the only thing that could change was the strings used to represent the two possible values declaring two string constants would overcome it. But the point is it's usually impossible to know what will change on a detailed level, so in software of any real complexity it's usually worth the upfront time to make code that is truly flexible. Doing so is mainly a matter of encapsulating as much as possible and making a habit of using virtual methods by default.

It's a pity that human nature makes it so difficult to take a truly long term view and think ahead. Whether it's climate change or software, we too often never even consider the implications of our actions until the mess we made has become rather difficult to clean up. A lot of code has a lifetime of at least 30 years, not in the sense that it's unchanged for that long or even that it's necessarily the same technology 30 years later, but in the sense that it continues to have direct implications for that long - even though it's been amended and bugfixed and optimized and refactored and ported and supposedly "cleaned up" many times.

I'm convinced of this, because I often refactor code in our only eight-year old codebase. Because absolutely everything is entangled with everything else, it's only possible to make improvements to specific parts of the system, while the complexity and chaos continues to increase at a far greater rate than we can untangle things. There may be many reasons for this, but the main one imho is quite simply that nobody ever tried to sit down and think about how to organize the code *for* long-term evolution. And I don't think we are alone in this.
GeneralRe: Wasted space Pin
justastupidgurl15-Oct-09 2:54
justastupidgurl15-Oct-09 2:54 
GeneralRe: Wasted space Pin
Richard MacCutchan19-Oct-09 23:58
mveRichard MacCutchan19-Oct-09 23:58 
GeneralRe: Wasted space Pin
OriginalGriff20-Oct-09 0:26
mveOriginalGriff20-Oct-09 0:26 
GeneralRe: Wasted space Pin
emunews11-Dec-09 11:36
emunews11-Dec-09 11:36 
GeneralHow to check if one date is bigger than another... Pin
Paulo Zemek29-Sep-09 3:26
mvaPaulo Zemek29-Sep-09 3:26 
GeneralRe: How to check if one date is bigger than another... Pin
Richard MacCutchan29-Sep-09 3:41
mveRichard MacCutchan29-Sep-09 3:41 
GeneralRe: How to check if one date is bigger than another... Pin
Jeroen De Dauw3-Oct-09 6:30
Jeroen De Dauw3-Oct-09 6:30 
GeneralRe: How to check if one date is bigger than another... Pin
QuiJohn23-Oct-09 2:44
QuiJohn23-Oct-09 2:44 
GeneralHow to chose self explanatory parameter names PinPopular
WilliamSauron25-Sep-09 0:20
WilliamSauron25-Sep-09 0:20 
GeneralRe: How to chose self explanatory parameter names Pin
egenis28-Sep-09 1:09
egenis28-Sep-09 1:09 
GeneralRe: How to chose self explanatory parameter names Pin
BillW3328-Sep-09 7:49
professionalBillW3328-Sep-09 7:49 
JokeRe: How to chose self explanatory parameter names Pin
Vasudevan Deepak Kumar1-Oct-09 1:27
Vasudevan Deepak Kumar1-Oct-09 1:27 
GeneralGet the date from SQL Server Pin
Alex Baker15-Sep-09 13:29
Alex Baker15-Sep-09 13:29 
GeneralRe: Get the date from SQL Server Pin
Rob Smiley16-Sep-09 4:24
Rob Smiley16-Sep-09 4:24 
GeneralRe: Get the date from SQL Server Pin
PIEBALDconsult16-Sep-09 5:39
mvePIEBALDconsult16-Sep-09 5:39 
GeneralRe: Get the date from SQL Server Pin
supercat917-Sep-09 5:40
supercat917-Sep-09 5:40 
GeneralRe: Get the date from SQL Server Pin
irol17-Sep-09 6:10
professionalirol17-Sep-09 6:10 

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.