Click here to Skip to main content
15,915,328 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.

 
GeneralBoth Weird & Wonderful - a W10 Surprise Pin
Rick York19-Aug-20 15:17
mveRick York19-Aug-20 15:17 
GeneralRe: Both Weird & Wonderful - a W10 Surprise Pin
Ron Anders19-Aug-20 15:56
Ron Anders19-Aug-20 15:56 
GeneralRe: Both Weird & Wonderful - a W10 Surprise PinPopular
Jon McKee19-Aug-20 17:28
professionalJon McKee19-Aug-20 17:28 
GeneralRe: Both Weird & Wonderful - a W10 Surprise Pin
Ron Anders19-Aug-20 17:44
Ron Anders19-Aug-20 17:44 
GeneralRe: Both Weird & Wonderful - a W10 Surprise Pin
Roger Wright2-Nov-20 11:07
professionalRoger Wright2-Nov-20 11:07 
GeneralRe: Both Weird & Wonderful - a W10 Surprise Pin
Nelek19-Aug-20 20:00
protectorNelek19-Aug-20 20:00 
GeneralRe: Both Weird & Wonderful - a W10 Surprise Pin
Randor 19-Aug-20 20:56
professional Randor 19-Aug-20 20:56 
GeneralRe: Both Weird & Wonderful - a W10 Surprise Pin
Nelek20-Aug-20 1:17
protectorNelek20-Aug-20 1:17 
GeneralRe: Both Weird & Wonderful - a W10 Surprise Pin
David O'Neil20-Aug-20 8:59
professionalDavid O'Neil20-Aug-20 8:59 
GeneralRe: Both Weird & Wonderful - a W10 Surprise Pin
mngerhold21-Aug-20 0:00
mngerhold21-Aug-20 0:00 
GeneralRe: Both Weird & Wonderful - a W10 Surprise Pin
David O'Neil21-Aug-20 0:09
professionalDavid O'Neil21-Aug-20 0:09 
GeneralRe: Both Weird & Wonderful - a W10 Surprise Pin
Saša Ćetković21-Aug-20 1:46
professionalSaša Ćetković21-Aug-20 1:46 
GeneralRe: Both Weird & Wonderful - a W10 Surprise Pin
Adar Wesley21-Aug-20 4:19
Adar Wesley21-Aug-20 4:19 
GeneralRe: Both Weird & Wonderful - a W10 Surprise Pin
F Margueirat21-Aug-20 4:16
F Margueirat21-Aug-20 4:16 
GeneralRe: Both Weird & Wonderful - a W10 Surprise Pin
Rick York21-Aug-20 5:07
mveRick York21-Aug-20 5:07 
GeneralRe: Both Weird & Wonderful - a W10 Surprise Pin
TnTinMn21-Aug-20 7:22
TnTinMn21-Aug-20 7:22 
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 
Writing a simple console app.
I wrote this to insure there is at least one argument provided by user.
C#
if (args.Length < 1){
      Console.WriteLine("Need at least one arg.");
      return;
}


Interesting thing is that Visual Studio Code has these little helpers that pop up at various times which state [Show fixes]. This one says, "invert if"[^].

If you click, it changes the code to:

C#
if (args.Length >= 1){
    return;
}
Console.WriteLine("Need at least one arg.");
return;

Do you find that clearer?
I don't.

In my case, the if statement occurs at the top and if it is not fulfilled then the app exits.
In that case there is no need to think about other code.
Plus, the code that executes normally will not be wrapped in any outer if statement, instead it will simply following the if statement in a normal reading flow.
Inverted Case
In the inverted if then when there is at least one argument then all of your base code is now wrapped in the if statement and you have to think backwards. It's weird.
AI you have failed me. Hmmm | :|
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 
GeneralRe: invert if : visual studio code helper Pin
SteakhouseLuke5-Aug-20 4:44
SteakhouseLuke5-Aug-20 4:44 

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.