O'Reilly logo

Testing with F# by Mikael Lundin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 2. Writing Testable Code with Functional Programming

There are three main aspects of writing code in a functional style in F# versus imperative style in a language such as C#:

  • No side effects leads to fewer bugs
  • Smaller isolated units are easier to test
  • Expressiveness makes code right the first time

This chapter will address the following bits about functional programming:

  • Purity
  • Expressiveness
  • Immutability
  • Patterns to help you write testable code

By reading this chapter, you will learn how to write high quality code that will become easy to test. This chapter sets the groundwork for how tests will be written in the following chapters.

Purely functional

What is a computer program?

The following image shows the basic working of a computer program: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required