ILoggable

A place to keep my thoughts on programming

Tag Archives: delegate

Ok, so there are still delegates you have to define

Yesterday I needed to create a bit of code that should retry an http request on failure and i wanted this to happen in a non-blocking fashion, so a plain loop was out. Using DReAM's Plug, I can easily set … Continue reading

February 15, 2011 .net

Func/Action vs. Delegate

A while back I wrote that you really never have to write another delegate again, since any delegate can easily be expressed as an Action or Func. After all what's preferable? This: var work = worker.ProcessTaskWithUser(delegate(Task t, User u) { … Continue reading

January 5, 2011 .net, geek , , ,

Ultimate Interface Segregation: Dependency injection by Delegate

I’ve been on a bit of a tear about declaring dependency contracts and injecting only what is required. While examining the use of Interfaces in IoC and their shortcomings, I decided that taken to the extreme, dependencies come down to … Continue reading

June 20, 2009 geek , , ,

More Deferred Execution Fun: foreach and delegation scope

This is closely related to my last post on deferred execution gotchas and its basically more “if you inline delegated code, you may easily overlook scope side-effects”. This time it’s about dealing with foreach and using the local each item … Continue reading

January 11, 2008 .net , , ,

The dangers of deferred execution

I recently wrote about Action & Func, which along with Lambda expression let you do easy inline callbacks like this: Utility.ActionDownloader.Download( Configuration.GetAssetUri(dto.Url), (Downloader d) => { FloatContainer c = (FloatContainer)XamlReader.Load(d.ResponseText); c.Initialize(dto); }); i.e. I can call a downloader and inline … Continue reading

December 30, 2007 .net , ,

Action & Func: Never write another delegate

With lambda expressions in C#, the Func generic delegate and it's variations have been getting a lot of attention. So naturally, you might think that the lambda syntax is just a shortcut for creating anonymous delegates, whether they return values … Continue reading

December 14, 2007 .net , ,

Are delegates the reason we have C#?

This may be ancient news, but I just came across an article that strongly implied that the reason .NET came about was because Sun didn’t like Microsoft’s addition of delegates to J++. That surely is a condensation of events, but … Continue reading

April 9, 2007 .net, geek , , , , ,

Delegates in Javascript

I’ve recently been doing javascript coding again. Being the object bigot that I am, everything that interacts with a DOM element gets wrapped in an object that becomes responsible for that element’s behavior. Well, then i tried to move all … Continue reading

July 26, 2006 javascript