Click here to Skip to main content
15,890,438 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: For loop Pin
Ennis Ray Lynch, Jr.13-Mar-07 4:59
Ennis Ray Lynch, Jr.13-Mar-07 4:59 
GeneralRe: For loop Pin
reshi99913-Mar-07 5:54
reshi99913-Mar-07 5:54 
GeneralRe: For loop Pin
Daniel Turini13-Mar-07 10:23
Daniel Turini13-Mar-07 10:23 
GeneralRe: For loop Pin
V.13-Mar-07 22:51
professionalV.13-Mar-07 22:51 
GeneralRe: For loop Pin
Captain See Sharp14-Mar-07 13:15
Captain See Sharp14-Mar-07 13:15 
JokeRe: For loop Pin
imagiro28-Apr-07 4:49
imagiro28-Apr-07 4:49 
JokeRe: For loop Pin
Sylvester george22-Jun-07 0:25
Sylvester george22-Jun-07 0:25 
GeneralIt always worked well before so leave it like that... [modified] Pin
Stephan Poirier12-Mar-07 21:04
Stephan Poirier12-Mar-07 21:04 
A couple of year ago, I worked for a compagny who were making vision sensing application for wood machinery. Their code (in C++) was a lot complicated, with lots of subclassing, and for the worst part of it, almost every options parameters controlling the code sequence were implemented with #if #then to "save some processor time". (The main core of the program was developped in Turbo-Dos like 15 years ago, then ported to Visual 6.0. It's why they used those #if #then...) The code was more than 3 millions line of code!!!

That's it for the introduction. (You may already laugh!!)

But one day, I came across a fonction used to connect a RS232 port.
This is the interesting part inside the fonction :

...some code here

if( strcmp( lpszPortName, "COM1") == 0 );
{
// Connect the COM1 port
...some code here
}
else if( strcmp( lpszPortName, "COM2") == 0 )
{
// Connect the COM2 port
...some code here
}
else
...

So I asked one of the guy who were working there since a very long time, why they didn't corrected that error... He told me "It always worked well before, and the compiler never notified any error so leave it like that..."

Do you know why I found this little error in 3 millions of code lines? Because this sequence was part of a library used in the main program, and because that library had never been recompiled since its first release 10 years before! For some reasons, I just forgot to follow a little "office rule" that was to never recompile all projects in a workspace in a single shot. I did it "oh unfortunately" then the compiler hit that error immediately!!


Progamming looks like taking drugs...
I think I did an overdose. Poke tongue | ;-P


-- modified at 3:09 Tuesday 13th March, 2007
GeneralRe: It always worked well before so leave it like that... Pin
Hal Angseesing12-Mar-07 22:16
professionalHal Angseesing12-Mar-07 22:16 
GeneralRe: It always worked well before so leave it like that... Pin
Stephan Poirier13-Mar-07 17:26
Stephan Poirier13-Mar-07 17:26 
GeneralRe: It always worked well before so leave it like that... Pin
Emil - Gabriel12-Mar-07 22:35
Emil - Gabriel12-Mar-07 22:35 
GeneralRe: It always worked well before so leave it like that... Pin
Stephan Poirier13-Mar-07 17:21
Stephan Poirier13-Mar-07 17:21 
GeneralRe: It always worked well before so leave it like that... Pin
Stephen Hewitt13-Mar-07 2:25
Stephen Hewitt13-Mar-07 2:25 
GeneralRe: It always worked well before so leave it like that... Pin
Pete O'Hanlon13-Mar-07 5:56
mvePete O'Hanlon13-Mar-07 5:56 
GeneralRe: It always worked well before so leave it like that... Pin
PIEBALDconsult13-Mar-07 8:14
mvePIEBALDconsult13-Mar-07 8:14 
GeneralRe: It always worked well before so leave it like that... Pin
Stephan Poirier13-Mar-07 17:10
Stephan Poirier13-Mar-07 17:10 
GeneralRe: It always worked well before so leave it like that... Pin
Stephan Poirier13-Mar-07 17:11
Stephan Poirier13-Mar-07 17:11 
GeneralRe: It always worked well before so leave it like that... Pin
John R. Shaw14-Mar-07 17:13
John R. Shaw14-Mar-07 17:13 
GeneralRe: It always worked well before so leave it like that... Pin
Stephan Poirier14-Mar-07 17:52
Stephan Poirier14-Mar-07 17:52 
GeneralRe: It always worked well before so leave it like that... Pin
vijay_aroli15-Mar-07 0:59
vijay_aroli15-Mar-07 0:59 
Generalif bool Pin
innominate12-Mar-07 10:01
innominate12-Mar-07 10:01 
GeneralRe: if bool Pin
Marcus J. Smith12-Mar-07 10:41
professionalMarcus J. Smith12-Mar-07 10:41 
GeneralCould've been worse Pin
Ravi Bhavnani12-Mar-07 10:49
professionalRavi Bhavnani12-Mar-07 10:49 
GeneralRe: if bool Pin
Kevin McFarlane12-Mar-07 11:12
Kevin McFarlane12-Mar-07 11:12 
GeneralRe: if bool Pin
PIEBALDconsult12-Mar-07 14:27
mvePIEBALDconsult12-Mar-07 14:27 

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.