Click here to Skip to main content
15,884,986 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: Both Weird & Wonderful - a W10 Surprise Pin
Rick York21-Aug-20 9:16
mveRick York21-Aug-20 9:16 
GeneralRe: Both Weird & Wonderful - a W10 Surprise Pin
patbob21-Aug-20 14:19
patbob21-Aug-20 14:19 
GeneralGoogle Docs and inline images (CP related) Pin
raddevus12-Aug-20 10:34
mvaraddevus12-Aug-20 10:34 
Generalinvert if : visual studio code helper Pin
raddevus4-Aug-20 5:15
mvaraddevus4-Aug-20 5:15 
GeneralRe: invert if : visual studio code helper Pin
honey the codewitch4-Aug-20 5:41
mvahoney the codewitch4-Aug-20 5:41 
GeneralRe: invert if : visual studio code helper Pin
raddevus4-Aug-20 6:02
mvaraddevus4-Aug-20 6:02 
GeneralRe: invert if : visual studio code helper Pin
Mircea Neacsu4-Aug-20 8:23
Mircea Neacsu4-Aug-20 8:23 
GeneralRe: invert if : visual studio code helper Pin
Nelek4-Aug-20 19:42
protectorNelek4-Aug-20 19:42 
I use the "first the constant" rule (I didn't know it was called "yoda conditionals", nice name hehehe) in comparisons for equality.

But for greater / lower than I don't use it for readability.I find it easier to read when it is "var <= value" than "value >= var" in a check_lower_limit()

Same thing I try to make my conditions to be read as if (true)

I mean, I don't like "if (!var)", I prefer to write "if (false == var)" this way is 100% clear on the first sight.

Or naming the variables in a way that they meaning is "true". This is something that comes from working in industry PLCs. I have had sensors called "part_exist" where the "1" was meaning "empty" (security against cable breaks), to look an "if (part_exist_x == true) PutPartInPlace(x);" Dead | X| Dead | X| Dead | X|
I always renamed such sensors to follow the rule "name means true" so that the same condition check as above would read "if (place_empty_x == true) PutPartInPlace(x);"

Just personal taste...
M.D.V. Wink | ;)

If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.

GeneralRe: invert if : visual studio code helper Pin
SteakhouseLuke5-Aug-20 4:44
SteakhouseLuke5-Aug-20 4:44 
GeneralRe: invert if : visual studio code helper Pin
Nelek5-Aug-20 6:55
protectorNelek5-Aug-20 6:55 
GeneralRe: invert if : visual studio code helper Pin
englebart23-Aug-20 8:01
professionalenglebart23-Aug-20 8:01 
GeneralRe: invert if : visual studio code helper Pin
Mircea Neacsu23-Aug-20 9:03
Mircea Neacsu23-Aug-20 9:03 
GeneralRe: invert if : visual studio code helper Pin
Maximilien4-Aug-20 5:52
Maximilien4-Aug-20 5:52 
GeneralRe: invert if : visual studio code helper Pin
raddevus4-Aug-20 6:04
mvaraddevus4-Aug-20 6:04 
GeneralRe: invert if : visual studio code helper Pin
Nelek4-Aug-20 8:18
protectorNelek4-Aug-20 8:18 
GeneralRe: invert if : visual studio code helper Pin
raddevus4-Aug-20 8:39
mvaraddevus4-Aug-20 8:39 
GeneralRe: invert if : visual studio code helper Pin
Jon McKee4-Aug-20 10:44
professionalJon McKee4-Aug-20 10:44 
GeneralRe: invert if : visual studio code helper Pin
raddevus4-Aug-20 11:40
mvaraddevus4-Aug-20 11:40 
GeneralRe: invert if : visual studio code helper Pin
Jon McKee4-Aug-20 12:11
professionalJon McKee4-Aug-20 12:11 
GeneralRe: invert if : visual studio code helper Pin
raddevus4-Aug-20 16:43
mvaraddevus4-Aug-20 16:43 
GeneralRe: invert if : visual studio code helper Pin
Richard Deeming4-Aug-20 23:41
mveRichard Deeming4-Aug-20 23:41 
GeneralRe: invert if : visual studio code helper Pin
raddevus5-Aug-20 2:14
mvaraddevus5-Aug-20 2:14 
GeneralRe: invert if : visual studio code helper Pin
Jon McKee12-Aug-20 11:14
professionalJon McKee12-Aug-20 11:14 
GeneralRe: invert if : visual studio code helper Pin
Richard Deeming12-Aug-20 22:18
mveRichard Deeming12-Aug-20 22:18 
GeneralRe: invert if : visual studio code helper Pin
Bernhard Hiller4-Aug-20 20:31
Bernhard Hiller4-Aug-20 20:31 

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.