Click here to Skip to main content
15,885,032 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: Austin Danger Powers Pin
_Erik_13-Apr-11 5:16
_Erik_13-Apr-11 5:16 
GeneralRe: Austin Danger Powers Pin
AspDotNetDev13-Apr-11 6:46
protectorAspDotNetDev13-Apr-11 6:46 
GeneralRe: Austin Danger Powers Pin
TorstenFrings13-Apr-11 23:09
TorstenFrings13-Apr-11 23:09 
GeneralRe: Austin Danger Powers Pin
AspDotNetDev20-Apr-11 7:08
protectorAspDotNetDev20-Apr-11 7:08 
GeneralRe: Austin Danger Powers Pin
TorstenFrings20-Apr-11 23:32
TorstenFrings20-Apr-11 23:32 
GeneralRe: Austin Danger Powers Pin
AspDotNetDev21-Apr-11 7:56
protectorAspDotNetDev21-Apr-11 7:56 
GeneralRe: Austin Danger Powers Pin
Jassim Makki16-Apr-11 5:43
Jassim Makki16-Apr-11 5:43 
GeneralRevolutionary new way to iterate indexable collections. Who needs to know how many elements they have? PinPopular
Vladimir Svyatski9-Apr-11 2:24
professionalVladimir Svyatski9-Apr-11 2:24 
Recently I encountered brand new look at standard boring indexable collections like arrays or lists in code I worked on. To be more precise, at ways we usually use to iterate them. We no longer need properties or functions like: Length, Size, Count. See how it goes (example demonstrating the idea):
int[] someArray = new int[] {/*element initialization*/};
for (int i = 0; /*note, the loop is infinite here*/; i++)
{
   try
   {
      int item = someArray[i];
      //do some stuff here
   }
   catch(Exception e)
   {
      break;//Bingo, we're done!
   }
}

Smell the power! Lenght, Count, Size, etc. They are obsolete now. Smile | :) We will iterate an indexable collection item by item until it crashes and that means our iteration is finished. That's what try/catch block was really intended for!

P.S. int[] was used for demonstration purposes. You can try it at home with any indexable collection you want (in .NET, for example, any collection implementing IList or IList<T> will do just fine).
GeneralRe: Revolutionary new way to iterate indexable collections. Who needs to know how many elements they have? PinPopular
Uros Calakovic9-Apr-11 6:55
Uros Calakovic9-Apr-11 6:55 
GeneralRe: Revolutionary new way to iterate indexable collections. Who needs to know how many elements they have? Pin
BillW3312-Apr-11 3:06
professionalBillW3312-Apr-11 3:06 
GeneralLong Post! Re: Revolutionary new way to iterate indexable collections. Who needs to know how many elements they have? [modified] Pin
Keith Barrow16-Apr-11 6:34
professionalKeith Barrow16-Apr-11 6:34 
GeneralRe: Long Post! Re: Revolutionary new way to iterate indexable collections. Who needs to know how many elements they have? Pin
Vladimir Svyatski18-Apr-11 5:54
professionalVladimir Svyatski18-Apr-11 5:54 
GeneralRe: Long Post! Re: Revolutionary new way to iterate indexable collections. Who needs to know how many elements they have? Pin
Keith Barrow18-Apr-11 6:43
professionalKeith Barrow18-Apr-11 6:43 
GeneralRe: Revolutionary new way to iterate indexable collections. Who needs to know how many elements they have? Pin
DragonsRightWing22-Apr-11 7:44
DragonsRightWing22-Apr-11 7:44 
GeneralI frequently type un-compilable code or comments to myself... Pin
puromtec16-Apr-11 15:13
puromtec16-Apr-11 15:13 
GeneralRe: I frequently type un-compilable code or comments to myself... Pin
Sander Rossel6-Apr-11 19:38
professionalSander Rossel6-Apr-11 19:38 
GeneralRe: I frequently type un-compilable code or comments to myself... Pin
Jyothikarthik_N6-Apr-11 21:38
Jyothikarthik_N6-Apr-11 21:38 
GeneralRe: I frequently type un-compilable code or comments to myself... Pin
Sander Rossel7-Apr-11 6:51
professionalSander Rossel7-Apr-11 6:51 
GeneralRe: I frequently type un-compilable code or comments to myself... Pin
BillW337-Apr-11 7:23
professionalBillW337-Apr-11 7:23 
GeneralRe: I frequently type un-compilable code or comments to myself... Pin
Pete O'Hanlon7-Apr-11 8:47
mvePete O'Hanlon7-Apr-11 8:47 
GeneralRe: I frequently type un-compilable code or comments to myself... Pin
puromtec17-Apr-11 14:33
puromtec17-Apr-11 14:33 
GeneralRe: I frequently type un-compilable code or comments to myself... Pin
Jörgen Andersson7-Apr-11 22:39
professionalJörgen Andersson7-Apr-11 22:39 
GeneralRe: I frequently type un-compilable code or comments to myself... Pin
Pete O'Hanlon13-Apr-11 12:33
mvePete O'Hanlon13-Apr-11 12:33 
GeneralRe: I frequently type un-compilable code or comments to myself... Pin
Jörgen Andersson13-Apr-11 19:02
professionalJörgen Andersson13-Apr-11 19:02 
GeneralRe: I frequently type un-compilable code or comments to myself... Pin
BillW3322-Apr-11 10:09
professionalBillW3322-Apr-11 10:09 

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.