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

What this book covers

Chapter 1, Overview of OOP in .NET Core and C#, contains an overview of Object-oriented-programming (OOP) and how it applies to C#. This chapter serves as a refresher of the important constructs and features of OOP and C#, including inheritance, encapsulation, and polymorphism.

Chapter 2, Modern Software Design Patterns and Principles, catalogs and introduces different patterns used in modern software development. This chapter investigates a number of patterns and catalogs, such as SOLID, Gang of Four, and enterprise integration patterns, as well as a discussion of the software development lifecycle and other practices for software development.

Chapter 3, Implementing Design Patterns - Basics Part 1, deep dives into design patterns used to build applications in C#. Using the development of an example application, test-driven development, minimum viable product, and other patterns from the Gang of Four will be illustrated.

Chapter 4, Implementing Design Patterns - Basics Part 2, continues the deep dive into design patterns used to build applications in C#. The concepts of Dependency Injection and Inversion of Control will be introduced as well, continuing to explore design patterns including the Singleton and Factory patterns.

Chapter 5, Implementing Design Patterns - .NET Core, builds upon chapters 3 and 4 by exploring patterns provided by the .NET Core. Several patterns, including Dependency Injection and the Factory pattern, will be revisited using the .NET Core framework.

Chapter 6, Implementing Design Patterns for Web Applications - Part 1, continues to explore .NET Core by looking at the features supported in web application development by continuing to build the sample application. This chapter offers guidance on creating an initial web application, discusses the important characteristics of a web application, and introduces how to create CRUD website pages.

Chapter 7, Implementing Design Patterns for Web Applications - Part 2, continues the exploration of web application development using .NET Core by looking at different architectural patterns, as well as solution security patterns. Authentication and authorization are covered as well. Unit tests are added including using the Moq mocking framework.

Chapter 8, Concurrent Programming in .NET Core, dives deeper into web application development to discuss concurrency in C# and .NET Core application development. The Async/await pattern is explored, as well as a section about multithreading and concurrency. Parallel LINQ is also covered, including delayed execution and thread priorities.

Chapter 9, Functional Programming Practices, explores functional programming in .NET Core. This includes illustrating the C# language features that support functional programming and applying them to the sample application, including applying the strategy pattern.

Chapter 10, Reactive Programming Patterns and Techniques, continues to build upon .NET Core web application development by exploring reactive programming patterns and techniques used to build responsive and scalable websites. In this chapter, the principles of reactive programming are explored, including the Reactive and IObservable patterns. Different frameworks are also discussed, including the popular .NET Rx Extensions, as well as an illustration of the Model-view-viewmodel (MVVM) pattern.

Chapter 11, Advanced Database Design and Application Techniques, explores patterns used in database design, including a discussion of databases. A practical example of applying the Command Query Responsibility Segregation pattern is shown, including using a ledger-style database design.

Chapter 12, Coding for the Cloud, looks at application development as it applies to cloud-based solutions, including the five key concerns of scalability, availability, security, application design, and DevOps. Significant patterns used in cloud-based solutions are explained, including different types of scaling, and patterns used in event-driven architecture, federated security, cache, and telemetry.

Appendix A, Miscellaneous Best Practices, wraps up the discussion of patterns by covering additional patterns and best practices. This includes a section about use case modeling, best practices, and additional patterns such as space-based architecture and containerized applications.