Lesson 29. Capstone 5

 

Now that you’ve finished this unit, let’s wrap up by applying these lessons back to the Bank Accounts application that you’ve been working on. You’ll see how to

  • Integrate your existing F# code base with a C# WPF application
  • Use third-party NuGet libraries within your F# code base
  • Observe how F# domains resolve up to C# in a real solution

29.1. Defining the problem

The objective of this capstone is to plug a C# Windows Presentation Foundation (WPF) GUI on top of the existing F# code base, replacing the console program runner with an event-driven UI. The system will provide the same Withdraw and Deposit commands as the console, as well as an updating transaction history. You can see how this looks in figure 29.1.

Figure 29.1. Sample WPF GUI for the Bank Accounts application
I don’t know WPF!

Because you may not be familiar with WPF (or even GUI programming at all), you’ll find a prebuilt GUI solution here using the Model-View-ViewModel (MVVM) design pattern. If you’re a WPF whiz, feel free to scrap the supplied solution and start again! But the objective of this capstone isn’t to get bogged down in the depths of WPF (and if you’ve done any WPF or Silverlight in the past, you’ll know just how complex things can get). Instead, you want to focus on the integration of the C# and F# worlds from a language point of view, as well as how the OO and FP paradigms work together.

29.1.1. Solution overview

29.2. Plugging in a third-party NuGet package

29.3. Connecting F# code to a WPF front end

29.4. Common fields on discriminated unions

29.5. Polishing up F# APIs for consumers

29.6. Working with pure functions in a mutable world

Summary