Book Image

Hands-On Design Patterns with C# and .NET Core

By : Gaurav Aroraa, Jeffrey Chilberto
Book Image

Hands-On Design Patterns with C# and .NET Core

By: Gaurav Aroraa, Jeffrey Chilberto

Overview of this book

Design patterns are essentially reusable solutions to common programming problems. When used correctly, they meet crucial software requirements with ease and reduce costs. This book will uncover effective ways to use design patterns and demonstrate their implementation with executable code specific to both C# and .NET Core. Hands-On Design Patterns with C# and .NET Core begins with an overview of object-oriented programming (OOP) and SOLID principles. It provides an in-depth explanation of the Gang of Four (GoF) design patterns, including creational, structural, and behavioral. The book then takes you through functional, reactive, and concurrent patterns, helping you write better code with streams, threads, and coroutines. Toward the end of the book, you’ll learn about the latest trends in architecture, exploring design patterns for microservices, serverless, and cloud native applications. You’ll even understand the considerations that need to be taken into account when choosing between different architectures such as microservices and MVC. By the end of the book, you will be able to write efficient and clear code and be comfortable working on scalable and maintainable projects of any size.
Table of Contents (19 chapters)
Free Chapter
1
Section 1: Essentials of Design Patterns in C# and .NET Core
4
Section 2: Deep Dive into Utilities and Patterns in .NET Core
10
Section 3: Functional Programming, Reactive Programming, and Coding for the Cloud

To get the most out of this book

This book does assume some familiarity with OOP and C#. Though this book covers advanced topics, it is not designed to be a comprehensive development guide. Instead, the goal of the book is to advance the skill levels of developers and designers by providing a wide array of patterns, practices, and principles. Using a toolbox analogy, the book provides a large number of tools for the modern application developer by progressing from low-level code design to higher-level architecture, as well as important patterns and principles commonly used today.

This book brought the following main points that are additions to readers knowledge:

  • To know more about SOLID Principles, best practices with the help of coding examples using C#7.x and .NET Core 2.2.
  • In-depth understanding of classic design pattern (Gang of four patterns).
  • Functional programming principle and its working examples using C# language.
  • Real world examples of Architectural patterns (MVC, MVVM).
  • Understanding of native cloud, microservices and more.

Download the example code files

You can download the example code files for this book from your account at www.packt.com. If you purchased this book elsewhere, you can visit www.packt.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

  1. Log in or register at www.packt.com.
  2. Select the SUPPORT tab.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR/7-Zip for Windows
  • Zipeg/iZip/UnRarX for Mac
  • 7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Hands-On-Design-Patterns-with-C-and-.NET-Core. In case there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Code in Action

Download the color images

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "The three CounterA(), CounterB(), and CounterC() methods represent an individual ticket collection counter."

A block of code is set as follows:

3-counters are serving...
Next person from row
Person A is collecting ticket from Counter A
Person B is collecting ticket from Counter B
Person C is collecting ticket from Counter C

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

public bool UpdateQuantity(string name, int quantity)
{
lock (_lock)
{
_books[name].Quantity += quantity;
}

return true;
}

Any command-line input or output is written as follows:

dotnet new sln

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "From Create New Product, you can add a new product, and Edit will give you the facility to update an existing product."

Warnings or important notes appear like this.
Tips and tricks appear like this.