Click here to Skip to main content
15,888,293 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: IIF to the rescue... Pin
Sander Rossel2-Jul-14 0:58
professionalSander Rossel2-Jul-14 0:58 
GeneralRe: IIF to the rescue... Pin
Nagy Vilmos30-Jun-14 23:43
professionalNagy Vilmos30-Jun-14 23:43 
GeneralRe: IIF to the rescue... Pin
Sander Rossel1-Jul-14 0:16
professionalSander Rossel1-Jul-14 0:16 
GeneralRe: IIF to the rescue... Pin
Richard Deeming1-Jul-14 2:33
mveRichard Deeming1-Jul-14 2:33 
GeneralRe: IIF to the rescue... Pin
PaulLinton2-Jul-14 15:14
PaulLinton2-Jul-14 15:14 
GeneralRe: IIF to the rescue... Pin
Sander Rossel2-Jul-14 19:31
professionalSander Rossel2-Jul-14 19:31 
GeneralRe: IIF to the rescue... Pin
Jörgen Andersson5-Jul-14 20:02
professionalJörgen Andersson5-Jul-14 20:02 
GeneralStarting to page OS to disk! Pin
David O'Neil27-Jun-14 10:22
professionalDavid O'Neil27-Jun-14 10:22 
Been a while since I've made the computer hiccup, but last week had an interesting experience. A bug evidently caused everything to start paging to disk on Win7-64.

The short of it was in a window resizing routine the DC wasn't released correctly, so memory was being eaten quickly. Didn't realize it and continually resized for multi-seconds for fun. The computer started getting sluggish as heck. Opened up Resource Monitor and noted the memory increase upon resizing. But it was too late.

At bootup about 2 gigs is taken by all the background stuff I use. With the other progs, and the leak, my 4 Gigs main memory was exceeded. All well and good, but then the unexpected occurred: I watched the resource monitor show my memory opening up to the state where it only reported 560 MB or so being used! But none of the programs I had open closed at that point. They were VERY slow to respond, though!

A reboot fixed everything, and the bug was squashed in the next round. That's my tale. It fits the weird, but not the wonderful. For that you can have this piece of classic code I came upon in the project, which I just massively revised:
C#
Rect() {
   Rect(0, 0, 0, 0);
   }

That initializer wasn't doing what the original author thought it was doing...

Or if you want another, this was the original author's assert macro:
#ifdef DEBUG
#	define ASSERT (object)	((void)((object) || (AssertDebug(#object,__FILE__,__LINE__),1)))
#else
...

Used throughout the code like:
ASSERT(m_hWnd);

If it is expanded, Visual Studio throws a bunch of "103 IntelliSense: '#' not expected here" errors. I don't think they ever #defined DEBUG in their code, so the asserts were never even used. I guess they just liked typing... (Or maybe VS6 expanded macros differently?)

GeneralChecking for empty guid Pin
Stepan Kobzey26-Jun-14 10:04
Stepan Kobzey26-Jun-14 10:04 
GeneralRe: Checking for empty guid Pin
PIEBALDconsult26-Jun-14 10:13
mvePIEBALDconsult26-Jun-14 10:13 
GeneralRe: Checking for empty guid Pin
Stepan Kobzey26-Jun-14 10:16
Stepan Kobzey26-Jun-14 10:16 
GeneralRe: Checking for empty guid Pin
PIEBALDconsult26-Jun-14 10:37
mvePIEBALDconsult26-Jun-14 10:37 
GeneralRe: Checking for empty guid Pin
Sander Rossel26-Jun-14 10:51
professionalSander Rossel26-Jun-14 10:51 
GeneralRe: Checking for empty guid PinPopular
PIEBALDconsult26-Jun-14 11:05
mvePIEBALDconsult26-Jun-14 11:05 
GeneralRe: Checking for empty guid Pin
Sander Rossel26-Jun-14 12:32
professionalSander Rossel26-Jun-14 12:32 
GeneralRe: Checking for empty guid Pin
OriginalGriff26-Jun-14 11:11
mveOriginalGriff26-Jun-14 11:11 
GeneralRe: Checking for empty guid Pin
Sander Rossel26-Jun-14 12:32
professionalSander Rossel26-Jun-14 12:32 
GeneralRe: Checking for empty guid Pin
PIEBALDconsult27-Jun-14 4:37
mvePIEBALDconsult27-Jun-14 4:37 
GeneralRe: Checking for empty guid Pin
JMK-NI26-Jun-14 11:19
professionalJMK-NI26-Jun-14 11:19 
GeneralRe: Checking for empty guid Pin
Bernhard Hiller27-Jun-14 0:11
Bernhard Hiller27-Jun-14 0:11 
GeneralRe: Checking for empty guid Pin
PIEBALDconsult27-Jun-14 4:37
mvePIEBALDconsult27-Jun-14 4:37 
GeneralRe: Checking for empty guid Pin
Bernhard Hiller27-Jun-14 0:06
Bernhard Hiller27-Jun-14 0:06 
GeneralRe: Checking for empty guid Pin
PIEBALDconsult27-Jun-14 4:38
mvePIEBALDconsult27-Jun-14 4:38 
GeneralRe: Checking for empty guid Pin
Nagy Vilmos27-Jun-14 1:59
professionalNagy Vilmos27-Jun-14 1:59 
GeneralRe: Checking for empty guid Pin
Richard Deeming27-Jun-14 2:36
mveRichard Deeming27-Jun-14 2:36 

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.