Book Image

Testing with F#

By : Mikael Lundin
Book Image

Testing with F#

By: Mikael Lundin

Overview of this book

Table of Contents (17 chapters)
Testing with F#
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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.