- In the art of functional programming, one can hand an anonymous delegate, as wrapped in a Func perhaps, to data (I envision a Func being handed to a method on a repository) in lieu of the usual thing in which an object is handed into a method. In the functional programming approach, the receiving method needs only know that it is to run a function of a certain <object,object> shape and nothing more. The functionality that the method fires is thus not shaped by the method itself and is instead shaped by what is handed in. Yay!
- The line of code that calls a method and the method itself are loosely coupled by way of a Func. You could put another Func "in front" of a Func too to chain them sequentially and then later detach the first Func as a something run by the second Func if you desire.
- One may spool up delegates and ultimately execute spools of delegates.
- Closures allow one to encapsulate some behavior and then pass it around like any other object. What is more, apparently state may be retained in closures! This is next for me to research.
Sunday, October 2, 2011
noob question: why should I care about delegates?
I just had a good conversation about delegates and I think I am beginning to understand why I should care a little bit better. It was not clear to me why I should want to use a pointer to a method instead of just calling the method. On the other side of the before mentioned discussion I understand:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment