Michael C said:
You'd absolutely hate my code then. I don't really see why you'd place
such restrictions on yourself really. Why would you write a function with
just "return x> 5" in it? Surely that's more difficult to read?
I wouldn't, but when there are half a dozen different places in the Linq
statement that require Lambdas that are looking at deep properties of the
object I'm selecting, *then* I start factoring them out into real functions.
Because of the one-line limitation on Lambdas right now, that often means I
can rationalise multiple Lambdas into one multi-line function anyway. To
me, that looks *far* more readable because I'm simply calling "...Where
IsRadioActiveAndUnstable(element)..." instead of having a to create a few
separate Lambdas. It's more terse, lol.
Optimisation will probably eliminate duplicate functions anyway. Even VB6
would do this.
That isn't the point. If I have multiple different Linq statements that
perform similar or identical filters on the sequences I'm selecting from,
then doing it the Lambda way means I still have to write those Lambda
expressions multiple times. What happens when I want to change a filter
parameter slightly? I have multiple different Linq queries where I have to
alter those same Lambdas.
Regardless of what optimisations the compiler does, *I* want my code
centralised and flexible. Embedding multiple complex Lambda functions into
query statements is not the way to achieve that, IMO.
But we are the builder of houses and it's perfectly valid to decide to
build wood houses because it's easier to cut. Although the analogy is not
100% accurate because we end up with the same product whichever tool we
choose.
You're correct, my analogy was flawed.
A more correct analogy is to say "wood is a better material than stone
because I prefer using saws". Which, as you can see, is even more
ridiculous. Wood may be easier for you to work with due to your familiarity
with saws, it may be far more suitable for you because you find the masonry
tools clumsy, but a stone-mason will disagree with you for all the same
reasons.
It doesn't make one material better than the other - unless you're talking
in subjective terms.