Learning

Source code for Jason Dolinger’s Model-View-ViewModel presentation

December 3rd, 2008

Some time back, I posted Jason’s presentation on Model-View-ViewModel and dependency injection with WPF and Unity (if you haven’t checked it out yet, you really should… the stuff there is good for Silverlight, too).  There were numerous requests to take a look at the source code.  It’s now available here.

Getting started with F# : read a book!

November 11th, 2008

Recently, a colleague here at Lab49 asked whether there were any good books available to help getting developers unfamiliar with F# and functional programming started in the world of functional .NET. I had some ideas and thought I’d post them here.

(In his post below, Sergey mentioned that Luke Hoban, the F# product manager, gave a talk at the Lab on F#. We recorded that presentation and I’ll be posting it soon, so stay tuned.)

The question was if there was a good book for “a typical Java developer to learn F#”. The short answer is that there isn’t. F# is a pretty flying leap for a typical Java developer to make; you can approach F# from the .NET world (e.g. C#) or from other functional languages (e.g. its parent, OCaml), but it’s hard to see how one could do it from neither. That said, I know of three F#-focused books in print now that can serve as a guide:

-”Expert F#“, by F#’s creator Don Syme. This is the book I recommend. It’s not perfect but it’s a good introduction to F#, mostly suited for people coming from a .NET background. It’s very dense. It’s not for novice programmers, and assumes a good deal of expert general programming knowledge on the part of the reader. But it’s definitely the best out there. (It’s also a bit out of date since the release of the September 1.9.6.2 CTP, but still mostly relevant. I expect it will eventually get updated.)

-”Foundations of F#” by Robert Pickering. This one is simpler and more basic than the above, and might be useful for just getting started. It isn’t as illuminating as the above and won’t serve as a full guide on its own. If you’re ready to deep dive, go straight to Don Syme and pass this one by.

-”F# for Scientists.” This one is for scientists.

“Expert F#” is the best bet for really tackling this language.

Keep in mind that if you really want to get serious with F# as a platform you’ll eventually need to understand the .NET Framework and the CLR (for which the best book remains “CLR via C#” by Jeffrey Richter).

There are a couple of other books coming out that I’m looking forward to seeing. One, by Chris Smith, promises to be great and is slated for release next year (and has a truly bizarre image occupying its placeholder cover). Also check out Chris’s series on his blog solving Project Euler problems with F#, which show off some of F#’s core functionality and can be a nice intro to approaching problems in a functional way. Another, “Real-world Functional Programming in .NET” by Tomas Petricek, who used to work on the F# team, will deal with FP approaches in both .NET and C# (using LINQ).

Some other F# resources are:
Hubfs.com, where the minds behind F# monitor the boards and answer tough questions, and
Flying Frog Consultancy, who have done a lot of cool work with F#.

My advice: download the CTP, buy the Don Syme book, and have some functional fun.

Jason Dolinger on Model-View-ViewModel

November 6th, 2008

A while back, Jason Dolinger, a consultant here at Lab49, gave us a presentation on design in WPF with the Model-View-ViewModel pattern and the Unity dependency injection framework.

Jason started with an application that one would write in a “traditional” way, with button clicks handled by event-handlers in the code-behind that then updated other parts of the UI. Using WPF data-binding, Commands, and Unity, he transformed it, piece by piece, in a much more manageable, encapsulated, readable, and testable M-V-VM design. It was awesome.

It was so awesome, in fact, that after the presentation Jason recorded the demo for all to see here.

Check it out. It’s the most practically instructive explanation of WPF design I’ve seen.

UPDATE: I thought I should mention that while Jason’s presentation is geared towards WPF, the patterns he describes are very applicable for Silverlight as well. There are a few things to take note of, though:

1) Jason creates ViewModels that are DependencyObjects. For some (apparently undocumented) reason, DataContexts in Silverlight cannot be DependencyObject descendants. That means that you need to implement ViewModels as INotifyPropertyChanged (an option also available for WPF that Jason mentions in his video). This doesn’t fundamentally affect the pattern, but should be noted.

2) Unity, which Jason uses for dependency injection, is available for Silverlight right now as part of pre-release Composite WPF & Silverlight (Prism) v2. You can download it here. (I haven’t been able to find Unity for Silverlight as a separate download.)

3) Silverlight does not support bindings for Commands out of the box. It does, however, expose the ICommand interface. With just a little bit more work using an “Attached Behavior” approach, we can get the kind of Commanding that Jason uses in Silverlight as well. Check out the description here.

Learn Expression

August 19th, 2008

At the Microsoft Expression Community Learning Center:

Just starting out with Expression? We’ve collected tutorials, starter kits, Quick Start Guides, videos, and other helpful resources to get you started quickly. Get answers from fellow users on the Discussion Forums, read our FAQs, or contact Support: it’s all here. For any questions or comments about the training content, please visit the Expression Discussion Forums.

(hat tip: Paul Mooney)