LDNUG: Mixing functional and object oriented approaches to programming in C#
Date: 2010-04-02 23:11:07

On Wednesday evening my colleague http://mikewagg.blogspot.com/[Mike Wagg] and I presented http://www.markhneedham.com/blog/2010/01/31/ddd8-mixing-functional-and-object-oriented-approaches-to-programming-in-c/[a variation of a talk I originally presented at Developer Developer Developer 8] titled 'Mixing functional and object oriented approaches to programming in C#' to the London .NET User Group at Skillsmatter.

The slides from the talk are below and there is a http://skillsmatter.com/podcast/open-source-dot-net/mike-wagg-mark-needham-functional-and-oo-approaches-to-c-sharp-programming/zx-548[video of the talk on the Skillsmatter website].

*http://www.slideshare.net/markhneedham/mixing-functional-and-object-oriented-approaches-to-programming-in-c-3624944[Mixing functional and object oriented approaches to programming in C#]*

These were some of the lessons I learned from this version of the talk:

* I recently spent a bit of time flicking through Scott Berkun's 'http://www.amazon.com/gp/product/0596801998?ie=UTF8&tag=marneesblo-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=0596801998[Confessions of a Public Speaker]' and one of the suggestions he has is that *people aren't interested in how you got to your current opinion - they're more interested in hearing what you've got to say*. While I think a story based approach is more fun to watch, in the original version of this talk I felt I spent too much time detailing where ideas had come from even though that information didn't add much value to the talk. We cut that out this time and I think it worked better as a result.
* I haven't done a paired talk before but I found it a much more enjoyable experience than when I just presented on my own. Mike took the role of the object oriented guy interested in how functional can work in that context while I took the role of the guy who's really interested in functional programming and wants to put it into C# code whenever possible. It was quite fun playing those roles especially when I was showing some of the slides on passing functions around and continuation passing style as the code became more and more difficult to understand.
* http://www.zimakki.com/blog/[Zi] suggested that it would work better next time if we *paused at the end of slides with code on* so the audience would have time to let it soak in and ensure they understood what was going on so this is something to try for next time.
* Mike and I were unsure whether the introduction where he covered *how C# had evolved through the different versions* would be useful but this was a part of the talk which got a lot of positive feedback and several people mentioned that they had done something similar at their work place when explaining LINQ to colleagues.
* Liz Martin pointed out that the talk was effectively about *knowing your language and how to use it an effective way* without causing yourself too much pain. I think this is probably a fair summary and if taken further perhaps explains how we end up with different idiomatic patterns of use in each language.
* Next time I'd look to explain some of the more complicated functional code a bit better and perhaps build up to it with some simpler examples. This time it was more to demonstrate how impossible the code can become if you take a functional approach to the extreme in C#. It also seems like there is some overlap with some of the patterns of Domain Driven Design and how the fit in with these two approaches to programming.

We had a discussion afterwards about some resources for learning functional programming. These were some of the things mentioned and resources I find useful:

* http://www.markhneedham.com/blog/2009/05/24/real-world-functional-programming-book-review/[Real World Functional Programming] - I started learning about F# from this book and it provides a nice introduction to functional programming concepts with examples side by side in C# and F#.
* http://channel9.msdn.com/shows/Going+Deep/Lecture-Series-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-1/[Functional Programming Fundamentals] - Erik Meijer's series of lectures on functional programming based mainly around Haskell recorded for Microsoft's Channel 9. I've only watched a couple of these so far but they seem to provide a decent introduction.
* http://feeds2.feedburner.com/planet_fsharp[Planet F#] - a syndicator with posts by various people about what they're doing with F#.
* http://mitpress.mit.edu/sicp/[Structure and Interpretation of Computer Programs] - a computer science introductory text used in introductory courses at MIT. It's not only about functional programming but there are relevant sections.</ul>