Click here to Skip to main content
15,896,153 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: Reusable Code Pin
PIEBALDconsult5-May-07 6:00
mvePIEBALDconsult5-May-07 6:00 
GeneralRe: Reusable Code Pin
Sylvester george20-Jun-07 3:12
Sylvester george20-Jun-07 3:12 
GeneralThis is just beautiful! Pin
jchigg20001-May-07 5:59
jchigg20001-May-07 5:59 
GeneralRe: This is just beautiful! Pin
CPallini1-May-07 7:46
mveCPallini1-May-07 7:46 
GeneralRe: This is just beautiful! Pin
Pete O'Hanlon1-May-07 10:06
mvePete O'Hanlon1-May-07 10:06 
GeneralRe: This is just beautiful! Pin
The ANZAC2-May-07 0:31
The ANZAC2-May-07 0:31 
GeneralRe: This is just beautiful! Pin
NormDroid3-May-07 1:59
professionalNormDroid3-May-07 1:59 
GeneralI do it really often :) Pin
Kochise4-May-07 4:52
Kochise4-May-07 4:52 
It's one of my coding rules, which is really useful once you get the point :

if(NULL != l_poStrTest)
{ // Format error message
  l_poStrTest->Format
  ( "My code : %d"
  , l_nErrorCode
  );
}
else
{ // Error code
}


It's also all about defines :

#define MY_TEST

#ifndef MY_TEST
  int l_nSize = GetStringSize(l_poStrText);
#else // MY_TEST
//  int l_nSize = TempoFunc(l_poStrText);
#endif // MY_TEST


By doing so, I write the full structure of the code which is then ready to fill up, and it also helps to keep an eye-track of the execution logic (inequal statement first) so that you don't have to know if the test is about inequality (!= or #ifndef) or equality (== or #ifdef). You just have to spot the upper or lower block of code and see if it is defined/filled or not...

This also force to structure carefully your code and put some air between the lines, instead to write a rock-compact block of code...

Kochise

PS : I often write empty equality code like this

if(NULL != l_poStrTest)
{ // Format error message
  l_poStrTest->Format
  ( "My code : %d"
  , l_nErrorCode
  );
}
else{} // Error code, ready to be unrolled and filled with error handling code



In Code we trust !

GeneralRe: This is just beautiful! Pin
Sylvester george20-Jun-07 3:15
Sylvester george20-Jun-07 3:15 
GeneralMy introduction to "##" Pin
Todd_s0230-Apr-07 13:36
Todd_s0230-Apr-07 13:36 
GeneralRe: My introduction to "##" Pin
Michael Dunn30-Apr-07 14:22
sitebuilderMichael Dunn30-Apr-07 14:22 
GeneralRe: My introduction to "##" Pin
Pete O'Hanlon30-Apr-07 22:22
mvePete O'Hanlon30-Apr-07 22:22 
GeneralRe: My introduction to "##" Pin
Marcus J. Smith1-May-07 2:44
professionalMarcus J. Smith1-May-07 2:44 
GeneralRe: My introduction to "##" Pin
Tristan Rhodes1-May-07 5:38
Tristan Rhodes1-May-07 5:38 
GeneralRe: My introduction to "##" Pin
peterchen1-May-07 19:41
peterchen1-May-07 19:41 
GeneralRe: My introduction to "##" Pin
Tristan Rhodes2-May-07 8:59
Tristan Rhodes2-May-07 8:59 
GeneralRe: My introduction to "##" Pin
Pete O'Hanlon2-May-07 1:39
mvePete O'Hanlon2-May-07 1:39 
GeneralRe: My introduction to "##" Pin
peterchen1-May-07 10:45
peterchen1-May-07 10:45 
GeneralRe: My introduction to "##" Pin
PIEBALDconsult1-May-07 15:59
mvePIEBALDconsult1-May-07 15:59 
GeneralRe: My introduction to "##" Pin
peterchen1-May-07 19:31
peterchen1-May-07 19:31 
GeneralRe: My introduction to "##" Pin
PIEBALDconsult2-May-07 3:52
mvePIEBALDconsult2-May-07 3:52 
GeneralRe: My introduction to "##" Pin
Dan Neely2-May-07 3:55
Dan Neely2-May-07 3:55 
GeneralRe: My introduction to "##" Pin
PIEBALDconsult2-May-07 5:23
mvePIEBALDconsult2-May-07 5:23 
JokeRe: My introduction to "##" Pin
Dan Neely2-May-07 7:10
Dan Neely2-May-07 7:10 
GeneralRe: My introduction to "##" Pin
PIEBALDconsult2-May-07 11:11
mvePIEBALDconsult2-May-07 11:11 

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.