Re: Casting problem

Tech-Archive recommends: Fix windows errors by optimizing your registry




"Marc Gravell" <marc.gravell@xxxxxxxxx> wrote in message
news:fd6a60b4-76a9-4273-86ea-3cd8ce2deddd@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I like to consolidate where possible.

For the same reason to use anonymous functions (at least one of the
reasons).

Actually I'm all-up for anonymous methods for delegates; agree with
you strongly. Even better in C# 3 where you can use the much
abbreviated lambda syntax.

But there's a line smoewhere, between simpy consolidating, vs
deliberately banging your code out of shape to make it into one line/
statement; the fact that you have to ask how to do it in one statement
probably means you're on the far side of the line. It isn't helping
you, and it can *only* complicate the code. Fine if throwaway, but
most of the longterm cost of code is support/maintenance - which means
(in a typical corporate setupt) that you might not be the person
editing the code next time. If the next person has to stop and think
"what does this do?" then you've achieved an own goal; there are times
when simple code, and meaningful variable names go a long way towards
creating maintainable code.

Sounds reasonable. If it costs more to put it together and even more to
maintain, then it probably wasn't the best way to go.

It could be that in some cases it is harder to follow by putting 2
anonymous
delegates in one method call. Not incorrect, just hard to follow.

I agree - not incorrect (see LINQ...) - but I would advocate using
lambdas if possible; they make such things a lot easier to follow;
regardless of the body of the anon/lambda, the human eye/brain can
only see so much at once; a lambda takes only a fraction as much
effort to understand as an anon-method.

I haven't really done much with lambdas yet, but heard it was pretty neat.
Looking forward to playing with it.

Thanks,

Tom

Marc


.



Relevant Pages

  • Re: Casting problem
    ... For the same reason to use anonymous functions (at least one of the ... Actually I'm all-up for anonymous methods for delegates; ... delegates in one method call. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Delegate Math Still Doesnt Work for Clinton
    ... Play with this and tell me in what *reasonable* scenario Clinton ... Obama gets the nomination based on pledged delegates. ... Er, that's pretty much the sole reason they exist, isn't it? ...
    (rec.sport.football.college)
  • unbelievable pressure to quit from obama supporters
    ... The reason that hillary clinton she should stay in is - because she can. ... even if she comes out with less delegates and a lower popular vote, since when is doing that well a reason to give in to the male dominated egos. ...
    (alt.politics)
  • Re: Delegate Math Still Doesnt Work for Clinton
    ... Play with this and tell me in what *reasonable* scenario Clinton ... Obama gets the nomination based on pledged delegates. ... Er, that's pretty much the sole reason they exist, isn't it? ...
    (rec.sport.football.college)
  • Re: Function within method (Simple question?)
    ... | Jon Skeet wrote: ... the only similar thing is anonymous methods. ... |> However, unless I needed delegate behaviour, I'd normally just create ... any reason you want to create it within the ...
    (microsoft.public.dotnet.languages.csharp)