Book Image

.NET Design Patterns

By : Praseed Pai, Shine Xavier
Book Image

.NET Design Patterns

By: Praseed Pai, Shine Xavier

Overview of this book

Knowing about design patterns enables developers to improve their code base, promoting code reuse and making their design more robust. This book focuses on the practical aspects of programming in .NET. You will learn about some of the relevant design patterns (and their application) that are most widely used. We start with classic object-oriented programming (OOP) techniques, evaluate parallel programming and concurrency models, enhance implementations by mixing OOP and functional programming, and finally to the reactive programming model where functional programming and OOP are used in synergy to write better code. Throughout this book, we’ll show you how to deal with architecture/design techniques, GoF patterns, relevant patterns from other catalogs, functional programming, and reactive programming techniques. After reading this book, you will be able to convincingly leverage these design patterns (factory pattern, builder pattern, prototype pattern, adapter pattern, facade pattern, decorator pattern, observer pattern and so on) for your programs. You will also be able to write fluid functional code in .NET that would leverage concurrency and parallelism!
Table of Contents (22 chapters)
.NET Design Patterns
Credits
Foreword
About the Authors
About the Reviewers
www.PacktPub.com
Customer Feedback
Preface

Sample programs


Now that we have taken a detailed look at the core functional programming constructs, it's time to indulge in power play (with code of course). Let's learn to play the game with some hardcore sample programs.

Spell checker

This was inspired by Peter Norvig's (former Research Director at Google) technical blog on How to Write a Spelling Corrector. What is interesting is the way the solution has been envisaged. The solution employs the probability theory at its core to find all possible corrections for a word of length n, by accounting for user errors in the form of typos arising because of omissions (deletes), characters misplaced (replaces and transposes), and inserted (inserts).

You can refer to this technical blog on How to Write a Spelling Corrector  by Peter Norvig for the following:

Note

For a word of length n, there will be n deletions, n-1 transpositions, 26n replacements, and 26(n+1) insertions.

To have fair shot at determining the corrections, we do find all possible corrections...