Click here to Skip to main content
15,883,749 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: Make sure this value is returned... Pin
cmger18-Jul-12 4:34
cmger18-Jul-12 4:34 
GeneralRe: Make sure this value is returned... Pin
Andrei Straut18-Jul-12 4:56
Andrei Straut18-Jul-12 4:56 
GeneralRe: Make sure this value is returned... Pin
BillW3318-Jul-12 6:32
professionalBillW3318-Jul-12 6:32 
GeneralRe: Make sure this value is returned... Pin
cmger18-Jul-12 20:34
cmger18-Jul-12 20:34 
GeneralRe: Make sure this value is returned... Pin
BillW3319-Jul-12 7:22
professionalBillW3319-Jul-12 7:22 
GeneralRe: Make sure this value is returned... Pin
greldak18-Jul-12 21:53
greldak18-Jul-12 21:53 
GeneralRe: Make sure this value is returned... Pin
Renzo Ciafardone19-Jul-12 7:24
Renzo Ciafardone19-Jul-12 7:24 
GeneralA new definition of efficiency PinPopular
PaulLinton16-Jul-12 19:57
PaulLinton16-Jul-12 19:57 
Just saw this posted on another forum
C#
List<char> _chars = new List<char>();
 
for (int i = 0; i < 2000; i++)
 {
 if ((i >= 48 && i <= 57) || (i >= 97 && i <= 122))
 {
 _chars.Add((char)i);
 }
 }

The author claimed that the code "work efficiently". I wonder how the upper limit of 2000 was determined? Why not int.MaxValue? Then you could maximise the inefficiency. Of course, you could do better with a long, or a lower bound of int.MinValue but that's getting silly.

The way _chars was used later all that was required was
C#
string _chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";

GeneralRe: A new definition of efficiency Pin
enhzflep16-Jul-12 20:31
enhzflep16-Jul-12 20:31 
GeneralRe: A new definition of efficiency Pin
RobCroll16-Jul-12 21:13
RobCroll16-Jul-12 21:13 
GeneralRe: A new definition of efficiency PinPopular
OriginalGriff16-Jul-12 22:39
mveOriginalGriff16-Jul-12 22:39 
JokeRe: A new definition of efficiency PinPopular
Andrew Rissing17-Jul-12 4:23
Andrew Rissing17-Jul-12 4:23 
GeneralRe: A new definition of efficiency Pin
OriginalGriff17-Jul-12 4:45
mveOriginalGriff17-Jul-12 4:45 
GeneralRe: A new definition of efficiency PinPopular
Andrew Rissing17-Jul-12 5:26
Andrew Rissing17-Jul-12 5:26 
GeneralRe: A new definition of efficiency Pin
SortaCore18-Jul-12 19:39
SortaCore18-Jul-12 19:39 
GeneralRe: A new definition of efficiency Pin
_Amy18-Jul-12 0:06
professional_Amy18-Jul-12 0:06 
GeneralRe: A new definition of efficiency Pin
BillW3317-Jul-12 10:03
professionalBillW3317-Jul-12 10:03 
GeneralRe: A new definition of efficiency Pin
englebart19-Jul-12 2:02
professionalenglebart19-Jul-12 2:02 
GeneralThis guy don't know what margin property in CSS is. Pin
Hiren solanki12-Jul-12 23:08
Hiren solanki12-Jul-12 23:08 
GeneralRe: This guy don't know what margin property in CSS is. Pin
Andrei Straut12-Jul-12 23:46
Andrei Straut12-Jul-12 23:46 
GeneralRe: This guy don't know what margin property in CSS is. Pin
Hiren solanki12-Jul-12 23:58
Hiren solanki12-Jul-12 23:58 
GeneralRe: This guy don't know what margin property in CSS is. Pin
jsc4216-Jul-12 23:03
professionaljsc4216-Jul-12 23:03 
GeneralRe: This guy don't know what margin property in CSS is. Pin
_Amy18-Jul-12 0:15
professional_Amy18-Jul-12 0:15 
GeneralEvolution of a stored proc PinPopular
virang_2112-Jul-12 20:37
virang_2112-Jul-12 20:37 
GeneralRe: Evolution of a stored proc Pin
BobJanova12-Jul-12 23:23
BobJanova12-Jul-12 23:23 

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.