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

 
AnswerRe: Which code you suggest? Pin
BobJanova29-Jul-13 0:50
BobJanova29-Jul-13 0:50 
AnswerRe: Which code you suggest? Pin
irneb29-Jul-13 3:30
irneb29-Jul-13 3:30 
GeneralRe: Which code you suggest? Pin
jibalt19-Aug-13 23:31
jibalt19-Aug-13 23:31 
AnswerRe: Which code you suggest? Pin
Jonathan C Dickinson29-Jul-13 22:07
Jonathan C Dickinson29-Jul-13 22:07 
GeneralRe: Which code you suggest? Pin
jibalt19-Aug-13 23:34
jibalt19-Aug-13 23:34 
AnswerRe: Which code you suggest? Pin
PIEBALDconsult30-Jul-13 5:24
mvePIEBALDconsult30-Jul-13 5:24 
AnswerRe: Which code you suggest? Pin
DarkChuky CR30-Jul-13 6:48
DarkChuky CR30-Jul-13 6:48 
GeneralRe: Which code you suggest? Pin
johannesnestler1-Aug-13 4:27
johannesnestler1-Aug-13 4:27 
Hm, interesting,

I can agree a Little on your first point - although this is no practical thinking for most .NET developers, because the "perfomance" impact is outweighted by more expressive code - I do express something when I write "foreach" (I express I want to do something FOR EACH element, don't depend on index or IList, just IEnumerable, I won't need an index, I don't need a break condition, ...). So the additional 2 context variables used internally by the foreach loop are fast earned back...

Point 2 will never be decided on "the Internet" - recommended? - not by me - it depends to much on overall style of the code (a lot of coders first evaluate all arguments and do early returns) and personal choice - and if you do "Microoptimazations" in .NET like you/I did in old c++ days, you should do early returns - so, readability (for you) or performance?

Point 3, though irrelevant for this discussion because this code should break on any found case (op alternatives are not equivalent), but I'm wondering why you think setting the variable to the break condition and evaluate it again is faster than a break statement? If this is any faster (I will test) this is intersting to know - it seems you are the master of "high perfomance super optimized .NET code" - but I'm not shure if .NET is the right realm for code which needs this kind of optimizations - shouldn't we do such perf. critical things in native code?

Kind regards Johannes
GeneralRe: Which code you suggest? Pin
DarkChuky CR1-Aug-13 5:44
DarkChuky CR1-Aug-13 5:44 
GeneralRe: Which code you suggest? Pin
johannesnestler1-Aug-13 23:26
johannesnestler1-Aug-13 23:26 
AnswerRe: Which code you suggest? Pin
TheGreatAndPowerfulOz30-Jul-13 10:18
TheGreatAndPowerfulOz30-Jul-13 10:18 
AnswerRe: Which code you suggest? Pin
johannesnestler1-Aug-13 4:04
johannesnestler1-Aug-13 4:04 
AnswerRe: Which code you suggest? Pin
Vasudevan Deepak Kumar2-Aug-13 8:29
Vasudevan Deepak Kumar2-Aug-13 8:29 
GeneralMisaligned elephants Pin
Matthew Faithfull22-Jul-13 2:10
Matthew Faithfull22-Jul-13 2:10 
GeneralRe: Misaligned elephants Pin
Richard Deeming22-Jul-13 11:34
mveRichard Deeming22-Jul-13 11:34 
GeneralRe: Misaligned elephants Pin
Matthew Faithfull22-Jul-13 11:54
Matthew Faithfull22-Jul-13 11:54 
GeneralRe: Misaligned elephants Pin
ExcellentOrg22-Jul-13 21:25
ExcellentOrg22-Jul-13 21:25 
GeneralRe: Misaligned elephants Pin
enhzflep23-Jul-13 19:51
enhzflep23-Jul-13 19:51 
GeneralRe: Misaligned elephants Pin
Matthew Faithfull23-Jul-13 23:03
Matthew Faithfull23-Jul-13 23:03 
GeneralRe: Misaligned elephants Pin
enhzflep23-Jul-13 23:39
enhzflep23-Jul-13 23:39 
GeneralRe: Misaligned elephants Pin
Sentenryu24-Jul-13 0:38
Sentenryu24-Jul-13 0:38 
GeneralRe: Misaligned elephants Pin
Matthew Faithfull24-Jul-13 0:55
Matthew Faithfull24-Jul-13 0:55 
GeneralRe: Misaligned elephants Pin
Sentenryu24-Jul-13 1:18
Sentenryu24-Jul-13 1:18 
GeneralRe: Misaligned elephants Pin
Matthew Faithfull24-Jul-13 1:23
Matthew Faithfull24-Jul-13 1:23 
GeneralRe: Misaligned elephants Pin
RafagaX24-Jul-13 4:41
professionalRafagaX24-Jul-13 4:41 

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.