Click here to Skip to main content
15,899,825 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: Words cannot describe my pain Pin
adamsappel30-Oct-08 23:05
adamsappel30-Oct-08 23:05 
GeneralLocking horror: Am I going mad? Pin
ewan19-Oct-08 8:02
ewan19-Oct-08 8:02 
GeneralRe: Locking horror: Am I going mad? Pin
PIEBALDconsult19-Oct-08 15:51
mvePIEBALDconsult19-Oct-08 15:51 
GeneralRe: Locking horror: Am I going mad? Pin
Andrew Rissing24-Oct-08 3:57
Andrew Rissing24-Oct-08 3:57 
GeneralRe: Locking horror: Am I going mad? Pin
CPallini19-Oct-08 20:35
mveCPallini19-Oct-08 20:35 
GeneralRe: Locking horror: Am I going mad? Pin
Dust Signs19-Oct-08 21:05
Dust Signs19-Oct-08 21:05 
GeneralRe: Locking horror: Am I going mad? Pin
PIEBALDconsult20-Oct-08 5:42
mvePIEBALDconsult20-Oct-08 5:42 
GeneralC# - Arrays vs Arraylist PinPopular
snorkie15-Oct-08 8:39
professionalsnorkie15-Oct-08 8:39 
I was going through our documentation and noticed this gem. We had a senior developer who created our development standards. This was part of the document he wrote for us. We had the .NET 2.0 framework available to us (hint: Generics) when this was written. I hope you find this as entertaining as I did.

On a side note, when the efficiencies were brought to his attention and refuted with a sample app, he was indignant and would not even consider any other way. He no longer works here!

There are times that information needs to be collected and distributed around the program.  To aid in the collection of data and 
passing it, Microsoft added collections.  The two most popular are arrays and arraylists.

An array takes its space out of the near heap.  It is very possible to run this out by adding to the array.  Arraylist takes its 
space out of the far heap and in 64KB chunks.  When building the collection, arraylists are the best thing to use for speed.  
HOWEVER, when passing the information from method to method, an arraylist is not the most efficient taking up to 60,000 flops to pass 
the information therefore arrays are faster.

q:  How do we strike a happy medium on this?  
a:  Use both.  Since most of the data that we collect are strings, we can do the following.  Build the arraylist when collecting 
data, the pass the data to an array when collecting is complete.  The following code is a great example on this:

string[] results = new string[arraylist.count];
arraylist.CopyTo(results, 0);
return results;

GeneralRe: C# - Arrays vs Arraylist Pin
che335815-Oct-08 11:18
che335815-Oct-08 11:18 
GeneralRe: C# - Arrays vs Arraylist Pin
snorkie16-Oct-08 4:36
professionalsnorkie16-Oct-08 4:36 
GeneralRe: C# - Arrays vs Arraylist Pin
hamityildirim15-Oct-08 18:26
hamityildirim15-Oct-08 18:26 
GeneralRe: C# - Arrays vs Arraylist Pin
leppie15-Oct-08 20:18
leppie15-Oct-08 20:18 
GeneralRe: C# - Arrays vs Arraylist Pin
snorkie16-Oct-08 4:35
professionalsnorkie16-Oct-08 4:35 
GeneralRe: C# - Arrays vs Arraylist Pin
Eddy Vluggen22-Oct-08 23:32
professionalEddy Vluggen22-Oct-08 23:32 
JokeRe: C# - Arrays vs Arraylist Pin
megaadam17-Oct-08 2:50
professionalmegaadam17-Oct-08 2:50 
GeneralRe: C# - Arrays vs Arraylist Pin
Redwan Albougha17-Oct-08 15:45
Redwan Albougha17-Oct-08 15:45 
GeneralRe: C# - Arrays vs Arraylist Pin
Paul Conrad17-Oct-08 18:20
professionalPaul Conrad17-Oct-08 18:20 
GeneralRe: C# - Arrays vs Arraylist Pin
Mike Dimmick19-Oct-08 1:34
Mike Dimmick19-Oct-08 1:34 
GeneralRe: C# - Arrays vs Arraylist Pin
hamityildirim10-Nov-08 0:24
hamityildirim10-Nov-08 0:24 
GeneralRe: C# - Arrays vs Arraylist [modified] Pin
Megidolaon23-Feb-09 0:32
Megidolaon23-Feb-09 0:32 
Generalstdcall_api Pin
thoru8-Oct-08 2:11
thoru8-Oct-08 2:11 
GeneralRe: stdcall_api Pin
PIEBALDconsult8-Oct-08 3:15
mvePIEBALDconsult8-Oct-08 3:15 
GeneralRe: stdcall_api Pin
Rob Grainger10-Oct-08 0:53
Rob Grainger10-Oct-08 0:53 
GeneralRe: stdcall_api Pin
PIEBALDconsult10-Oct-08 8:47
mvePIEBALDconsult10-Oct-08 8:47 
AnswerRe: stdcall_api Pin
Redwan Albougha18-Oct-08 11:05
Redwan Albougha18-Oct-08 11:05 

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.