Click here to Skip to main content
15,896,496 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: What are the worst programming habits? Pin
David O'Neil24-Jun-14 9:50
professionalDavid O'Neil24-Jun-14 9:50 
GeneralRe: What are the worst programming habits? Pin
Jörgen Andersson24-Jun-14 10:16
professionalJörgen Andersson24-Jun-14 10:16 
GeneralRe: What are the worst programming habits? Pin
Duncan Edwards Jones24-Jun-14 10:35
professionalDuncan Edwards Jones24-Jun-14 10:35 
GeneralRe: What are the worst programming habits? Pin
Sander Rossel24-Jun-14 10:57
professionalSander Rossel24-Jun-14 10:57 
GeneralRe: What are the worst programming habits? Pin
CDP180224-Jun-14 11:41
CDP180224-Jun-14 11:41 
GeneralRe: What are the worst programming habits? Pin
PIEBALDconsult24-Jun-14 12:40
mvePIEBALDconsult24-Jun-14 12:40 
GeneralRe: What are the worst programming habits? Pin
Pete O'Hanlon24-Jun-14 11:53
mvePete O'Hanlon24-Jun-14 11:53 
GeneralRe: What are the worst programming habits? Pin
_Maxxx_24-Jun-14 15:54
professional_Maxxx_24-Jun-14 15:54 
Pete O'Hanlon wrote:
Secondly, learn how to use the power of LINQ, that Where statement is redundant so the statement can become myList.SingleOrDefault(p => p.Id == aUniqueId);


However, using Where(predicate).function rather than Function(predicate) is significantly faster.

Incidentally a straight forward While loop is more efficient than either.

So if efficiency is a concern (and we're not just talking close here, there's a big enough difference that it counts!) you need to be careful!

1.
var found = collectionClass.FirstOrDefault(i => i.Field == searchValue);

or
2.
var found = collectionClass.Where(i => i.Field == searchValue).FirstOrDefault();

or
3.
foreach(item in collectionClass)
{
if (item.Field = searchValue)
{
found = item;
break;
}
}

The results for 100,000 collection with 100,000 searches?

1. 'normal' 78.5
1. parallel 32.2
2. 'normal' 51.2
2. parallel 31.9
3. 29.9
PooperPig - Coming Soon

GeneralRe: What are the worst programming habits? Pin
Jörgen Andersson24-Jun-14 18:49
professionalJörgen Andersson24-Jun-14 18:49 
GeneralRe: What are the worst programming habits? Pin
_Maxxx_27-Jun-14 11:25
professional_Maxxx_27-Jun-14 11:25 
GeneralRe: What are the worst programming habits? Pin
Jörgen Andersson27-Jun-14 19:39
professionalJörgen Andersson27-Jun-14 19:39 
GeneralRe: What are the worst programming habits? Pin
_Maxxx_27-Jun-14 23:57
professional_Maxxx_27-Jun-14 23:57 
GeneralRe: What are the worst programming habits? Pin
User 58385224-Jun-14 14:51
User 58385224-Jun-14 14:51 
GeneralRe: What are the worst programming habits? Pin
_Maxxx_24-Jun-14 16:03
professional_Maxxx_24-Jun-14 16:03 
GeneralRe: What are the worst programming habits? Pin
Charl24-Jun-14 20:20
Charl24-Jun-14 20:20 
GeneralRe: What are the worst programming habits? Pin
Pete O'Hanlon25-Jun-14 2:10
mvePete O'Hanlon25-Jun-14 2:10 
GeneralRe: What are the worst programming habits? Pin
Plamen Dragiyski24-Jun-14 20:28
professionalPlamen Dragiyski24-Jun-14 20:28 
GeneralRe: What are the worst programming habits? Pin
R. Erasmus24-Jun-14 21:02
R. Erasmus24-Jun-14 21:02 
GeneralRe: What are the worst programming habits? Pin
R. Erasmus24-Jun-14 21:06
R. Erasmus24-Jun-14 21:06 
GeneralRe: What are the worst programming habits? Pin
Peter Adam24-Jun-14 21:23
professionalPeter Adam24-Jun-14 21:23 
GeneralRe: What are the worst programming habits? Pin
Stefan Bogdan24-Jun-14 21:23
Stefan Bogdan24-Jun-14 21:23 
GeneralRe: What are the worst programming habits? Pin
Member 906355624-Jun-14 21:52
Member 906355624-Jun-14 21:52 
GeneralRe: What are the worst programming habits? Pin
Rosenne24-Jun-14 22:00
Rosenne24-Jun-14 22:00 
GeneralRe: What are the worst programming habits? Pin
Mel Padden24-Jun-14 22:04
Mel Padden24-Jun-14 22:04 
GeneralRe: What are the worst programming habits? Pin
Fran Porretto25-Jun-14 0:56
Fran Porretto25-Jun-14 0:56 

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.