Lesson 14. Capstone 2

 

Before we move on to the next unit—collections—here’s another end-of-level bad guy for you to defeat. This time, we’ll shift our focus from the basics of coding in F# to the material covered in this unit. In this lesson you’ll be expected to

  • Develop a standalone F# application in Visual Studio
  • Model a domain by using records, tuples, and functions
  • Create reusable higher-order functions that can be altered through injected dependencies

That’s a lot to do, but if you take this step by step, you’ll do fine.

14.1. Defining the problem

In this exercise, you’re going to write a simple bank account system. It needs to have the following capabilities:

1.  The application should allow a customer to deposit and withdraw from an account that the customer owns, and maintain a running total of the balance in the account.

2.  If the customer tries to withdraw more money than is in the account, the transaction should be declined (the balance should stay as is).

3.  The system should write out all transactions to a data store when they’re attempted. The data store should be pluggable (filesystem, console, and so forth).

4.  The code shouldn’t be coupled to, for example, the filesystem or console input. It should be possible to access the code API directly without resorting to a console application.

5.  Another developer will review your work, and that developer should be able to easily access all of the preceding components in isolation from one another.

14.2. Some advice before you start...

14.3. Getting started

14.4. Creating a domain

14.5. Creating behaviors

14.6. Abstraction and reuse through higher-order functions

14.7. Writing a console application

14.8. Referencing files from scripts

Summary