Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Architecting ASP.NET Core Applications

You're reading from   Architecting ASP.NET Core Applications An atypical design patterns guide for .NET 8, C# 12, and beyond

Arrow left icon
Product type Paperback
Published in Mar 2024
Publisher Packt
ISBN-13 9781805123385
Length 806 pages
Edition 3rd Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Carl-Hugo Marcotte Carl-Hugo Marcotte
Author Profile Icon Carl-Hugo Marcotte
Carl-Hugo Marcotte
Arrow right icon
View More author details
Toc

Table of Contents (27) Chapters Close

Preface 1. Section 1: Principles and Methodologies FREE CHAPTER
2. Introduction 3. Automated Testing 4. Architectural Principles 5. REST APIs 6. Section 2: Designing with ASP.NET Core
7. Minimal APIs 8. Model-View-Controller 9. Strategy, Abstract Factory, and Singleton Design Patterns 10. Dependency Injection 11. Application Configuration and the Options Pattern 12. Logging Patterns 13. Section 3: Component Patterns
14. Structural Patterns 15. Behavioral Patterns 16. Operation Result Pattern 17. Section 4: Application Patterns 18. Layering and Clean Architecture 19. Object Mappers 20. Mediator and CQS Patterns 21. Getting Started with Vertical Slice Architecture 22. Request-EndPoint-Response (REPR) 23. Introduction to Microservices Architecture 24. Modular Monolith 25. Other Books You May Enjoy
26. Index

What this book covers

Section 1: Principles and Methodologies

This section contains the book’s foundations about automated testing, including xUnit, architectural principles like SOLID, and how to build REST APIs.

Chapter 1, Introduction, contains the prerequisites and an explanation of how the book works as well as a few important topics that will be useful to a software developer.

Chapter 2, Automated Testing, introduces you to the basics of unit testing and the xUnit testing framework as well as to some good practices and methodologies to help write tests.

Chapter 3, Architectural Principles, lays the architectural groundwork with crucial principles used throughout the book and extremely important to any engineer trying to write SOLID code.

Chapter 4, REST APIs, outlines HTTP basics, API versioning, the Data Transfer Object (DTO) pattern, and robust API contract design for RESTful services.

Section 2: Designing with ASP.NET Core

This section introduces ASP.NET Core-specific subjects, including Minimal API, Model-View-Controller (MVC), and other classic design patterns. We cover application configuration and logging patterns, two essential building blocks. We also deep dive into dependency injection and explore the evolved usage of certain patterns as pillars of modern software engineering.

Chapter 5, Minimal APIs, introduces the streamlined approach to building .NET applications. It emphasizes the advantages of minimal hosting and Minimal APIs offered in ASP.NET Core.

Chapter 6, Model-View-Controller, introduces you to the MVC pattern, focusing on web APIs. We also look at how to apply the DTO pattern with MVC.

Chapter 7, Strategy, Abstract Factory, and Singleton Design Patterns, introduces you to the traditional implementation of three GoF design patterns: Strategy, Abstract Factory, and Singleton, which influence algorithm encapsulation, object creation, and instance control.

Chapter 8, Dependency Injection, takes the ASP.NET Core dependency injection container for a ride, introducing you to one of the most important aspects of modern software development. This chapter connects ASP.NET Core and the SOLID principles. Once the basics of dependency injection are laid out, we review the previous three GoF design patterns and revisit them using dependency injection, opening up the way to build testable, flexible, and reliable software.

Chapter 9, Application Configuration and the Options Pattern, examines how to configure ASP.NET Core applications effectively using the Options pattern, which allows for loading configurations from multiple sources and using them seamlessly in our code.

Chapter 10, Logging Patterns, analyzes .NET’s built-in logging framework, detailing essentials like log levels, providers, configuring logs, and the concept of structured logging.

Section 3: Component Patterns

This section focuses on component design, where we study how an individual piece of software can be crafted to achieve a particular goal. We explore a few more GoF patterns that should help you design SOLID data structures and components as well as simplifying the complexity of your code by encapsulating your logic in smaller units.

Chapter 11, Structural Patterns, introduces four new GoF structural design patterns demonstrating how to dynamically extend class behaviors and organize object hierarchies to boost flexibility and reusability.

Chapter 12, Behavioral Patterns, introduces the Template Method and Chain of Responsibility patterns, demonstrating how to streamline system behaviors and organize complex algorithmic structures for extensibility and maintainability. The chapter concludes by mixing them together as a final improvement on the code sample’s design.

Chapter 13, Operation Result Pattern, explores the Operation Result pattern, detailing how to convey the success or failure of operations with messages and values, and how to implement this approach for robust error handling and status reporting in your applications.

Section 4: Application Patterns

This section takes a step toward application design and introduces layering, vertical slice architecture, Request-EndPoint-Response, microservices architecture, and Modular Monoliths. We overview each technique, making sure you know how to get started. We also cover different component-level patterns that help put those architectural styles together, like Object Mappers, Aggregate Services, Façade, Mediator, and CQRS patterns.

Chapter 14, Layering and Clean Architecture, introduces you to layering and Clean Architecture, covering the primary objectives behind the presentation, domain, data (persistence) layers, and their clean architecture counterparts, which is the apogee of layering. It also highlights the evolution of application design in the last few decades, helping you understand where it started (the beginning of the chapter) and where it is now (the end of the chapter).

Chapter 15, Object Mappers, covers object mapping techniques (copying an object into another) to simplify the transmission of model objects between layers using manual mapping and open source tools like AutoMapper and Mapperly. The chapter also introduces organization patterns like Aggregate Services and Façade.

Chapter 16, Mediator and CQS Patterns, introduces the Command Query Separation (CQS) and Mediator patterns. After covering those two patterns, we conclude with the practical application of MediatR—an open source library—to exemplify these concepts in real-world development.

Chapter 17, Getting Started with Vertical Slice Architecture, introduces Vertical Slice Architecture. It uses a number of the previous patterns and tools that we have explored to piece together a different way to see the design of an application. It also introduces FluentValidation, which gets added to MediatR and AutoMapper.

Chapter 18, Request-EndPoint-Response (REPR), introduces the REPR pattern, a method that refines application design with HTTP alignment, demonstrating its use with Minimal APIs and imparting strategies for building feature-centric software.

Chapter 19, Introduction to Microservices Architecture, outlines the core principles of microservices, what they are, what they are not, and discusses a few related patterns. It introduces many concepts, such as event-driven communication, Gateway, and Command Query Responsibility Segregation (CQRS) patterns, equipping you to design scalable systems.

Chapter 20, Modular Monolith, discusses the balance between traditional and microservices architecture with Modular Monoliths, offering a middle ground with segregated, well-defined modules for scalable, maintainable applications. This chapter also implements event-driven patterns using MassTransit—an open source library—to handle module communication.

Appendix

The Appendix explores numerous C# features spanning a wide range of versions, including .NET 8 and C# 12. If you don’t understand a piece of code in the book, that feature is most likely covered in the Appendix. Even if you understood all the code, you may find some good tips there. You can consult the Appendix on GitHub (https://adpg.link/net8-appendix).

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image