Geeks With Blogs
Here in Flyover Country Talking about Project Management, Risk, and Statistics

I find it interesting how people think... what makes sense to them, et.c so...

There's how I think...

SomeObject.ListOfPeople.FindAll(

type => type.GetType().Equals(typeOf(Individual))).ForEach

(person => { DoSomethingWithPerson(arg1, arg2);});

Pretty straight forward lambd Final all of x type in this collection and then do something to each one found. But coworker suggested this instead:

(from person in SomeObject.ListOfPeople

where person is  Individual

select person as Individual).ToList().ForEach(person => {DoSomethingWith Person(arg1, arg2);});

So both do the same thing... and there's no performance difference, just depending on the coder one way is more readable than the other. I happen to like lambdas but I'm on team where the devs find the more SQLish style to be better (sorry blanking on the formal LINQ name).

One thing that sinks my lambda though. ListOfPeople has to be an ObservableCollection<T> and that doesn not support the FindAll method, unlike the generic List<T>.  Digging a bit ObservableColleciton inherits from Collection<T> (makes sense) which is more limited than List<T> in methods provided. c'est la vie.

Posted on Monday, December 21, 2009 9:52 AM | Back to top


Comments on this post: Different mindsets....

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © edgaralgernon | Powered by: GeeksWithBlogs.net