Preface

Following design patterns is a well-known approach to writing better programs that captures and reuses the high-level abstractions that are common in many applications. This book will encourage you to develop an idiomatic F# coding skillset by fully embracing the functional-first F# paradigm. It will also help you harness this powerful instrument to write succinct, bug-free, and cross-platform code.

F# 4.0 Design Patterns will start off by helping you develop a functional way of thinking. We will show you how beneficial the functional-first paradigm is and how to use it to get the optimum results. The book will help you acquire the practical knowledge of the main functional design patterns, relationship of which with the traditional “Gang of Four” set is not straightforward.

We will take you through pattern matching, immutable data types, and sequences in F#. We will also uncover advanced functional patterns, look at polymorphic functions, see typical data crunching techniques, and learn adjusting code through augmentation and generalization. Lastly, we take a look at the advanced techniques to equip you with everything you may need to write flawless code. In addition, we will explore how the paradigm shift to functional-first affects the design principles and patterns of the object-oriented universe and wrap up the book with specifics of functional code troubleshooting.

By reading this book you will achieve the following goals:

  • Acquire the practical knowledge to use the main functional design patterns
  • Realign some imperative and object-oriented principles under the functional approach
  • Develop your confidence in building and combining first-order and higher-order functions
  • Learn how to use core language pattern matching effectively
  • Learn how to use embedded algebraic data types in place of custom types for added effectiveness and code succinctness
  • Navigate and use F# core libraries with ease by seeing patterns behind specific library functions
  • Recognize and measure the difference in resource consumption between sequences and materialized data structures
  • Master writing generic polymorphic code

What this book covers

Chapter 1, Begin Thinking Functionally, should help you in developing a manner of coding usually associated with the functional paradigm. It will equip you with the knowledge, the key concepts, and the target list of skills pertinent to the functional-first nature of F# programming language.

Chapter 2, Dissecting F# Origins and Design, will help you to find out the origins of F# contemporary design, how F# evolved, and what place it occupies in the .NET ecosystem.

Chapter 3, Basic Functions, helps you to acquire a firm foundation for idiomatic F# use. It gives you 360-degree review of the functional paradigm cornerstone, the notion of the function. You will be taught how to represent any solution as a assortment of functions plugged together with a handful of combinators. This chapter prepares you to absorb the main subject-the patterns of F# idiomatic use.

Chapter 4, Basic Pattern Matching, gives you a good grasp of the language mechanism that is put into at the core of the language to address any data transformations-F# pattern matching. The chapter covers basic pattern matching features leaving data decomposition and active patterns for the following chapters.

Chapter 5, Algebraic Data Types, shows you the patterns of using the F# standard algebraic data types (tuples, discriminated unions, and records) as a better alternative to developing custom types. It covers these types composition, equality, comparison, decomposition, and augmentation.

Chapter 6, Sequences - The Core of Data Processing Patterns, acquaints you with one of the most essential arrangements of functional programming, the sequences. Sequences lay in the foundation of few fundamental functional patterns, such as lazy evaluation, sequence generators, and sequences of indefinite lengths. This chapter also puts down a blueprint of data transformation patterns taxonomy.

Chapter 7, Advanced Techniques: Functions Revisited, builds upon already covered patterns of language use in functions, pattern matching, and sequences. It introduces readers to such F# patterns as recursion, folding, memoization, and continuation passing.

Chapter 8, Data Crunching - Data Transformation Patterns, continues to dig deeper into the data transformation patterns we began uncovering in relation to sequences. You are given a full taxonomy of polymorphic data transformation patterns captured by the F# 4.0 core library. Now you are fully prepared to blueprinting your designs with the help of highly optimized high quality library function compositions, mostly avoiding custom implementations.

Chapter 9, More Data Crunching, adds to the data transformation patterns defined by F# core library arrangement data queries with F# query expressions and data parsing with the help of type providers.

Chapter 10, Type Augmentation and Generic Computations, covers two F# usage patterns based on opposite type transformations-code generalization and code specialization. You will get a demonstration of the benefits that may be achieved through the application of these patterns.

Chapter 11, F# Expert Techniques, scratches the surface of really advanced F# patterns. We walk through the use of F# type providers, concurrent and reactive programming, and wrap up with metaprogramming.

Chapter 12, F# and OOP Principles/Design Patterns, correlates the book's vision of design patterns with those of the OOP paradigm. We will see that well-known OOP design principles and specific patterns may morph, diminish, or literally seize to be in the context of functional-first paradigm.

Chapter 13, Troubleshooting Functional Code, represents an important addendum to the main subject, showing how to develop following the explorative style, how the nature of problems with F# code development significantly shifts into compile-time from run-time, and how to address some typical issues.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset