Software Architecture with C# 12 and .NET 8 - 4th Edition (Early Access)

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

A book for the aspiring .NET software architect – design scalable and high-performance enterprise solutions using the latest features of C# 12 and .NET 8 Purchase of the print or Kindle book includes a free PDF eBook Key Features Create fully modular apps using proven techniques to overcome architectural challenges Solve scalability problems in web apps using enterprise architecture patterns Master new developments in .NET with the help of a case study Book Description Software architecture becomes important as your applications grow in size and complexity. Software Architecture with C# 12 and .NET 8 puts high-level design theory to work in a .NET context, teaching you the key skills, concepts, and best practices required to become an effective .NET software architect. This fourth edition puts new emphasis on a case study that will bring your skills to life. You’ll discover how to choose between different architectures and technologies at each level of the stack. You’ll take an even closer look at Blazor and explore OpenTelemetry for observability, as well as a free alternative to Kubernetes. Divided in three parts, this book starts with the fundamentals of software architecture, covering C# best practices, software domains, design patterns, DevOps principles, and more. The second part focuses on the technologies, from choosing data storage in the cloud to implementing frontend microservices and working with Serverless. You’ll learn about the main communication technologies used in microservices, such as REST API, gRPC, Azure Service Bus, and RabbitMQ. The final part takes you through a real-world case study where you’ll create software architecture for a travel agency. By the end of this book, you will be able to transform user requirements into architectural needs and deliver highly scalable enterprise-ready apps. What you will learn Program and maintain Azure DevOps and explore GitHub Projects Apply architectural approaches such as layered

Author(s): Gabriel Baptista; Francesco Abbruzzese
Publisher: Packt Publishing
Year: 2023

Language: English
Pages: 933

B19820_21
Software Architecture with C# 12 and .NET 8, Fourth Edition: Build enterprise applications using microservices, DevOps, EF Core, and design patterns for Azure
1 Understanding the Importance of Software Architecture
Before you begin: join our book community on Discord
What is software architecture?
Creating an Azure account
Software development process models
Reviewing traditional software development process models
Gathering the right information to design high-quality software
Understanding the requirements gathering process
Detecting exact user needs
Analyzing requirements
Writing the specifications
Understanding the principles of scalability, robustness, security, and performance
Reviewing the specification
Using design techniques as a helpful tool
Design Thinking
Design Sprint
Common cases where the requirements gathering process impacts system results
Case 1 – my website is too slow to open that page!
Case 2 – the user’s needs are not properly implemented
Case 3 – the usability of the system does not meet the user’s needs
Summary
Questions
Further reading
2 Non-Functional Requirements
Before you begin: join our book community on Discord
Technical requirements
Enabling scalability, availability, and resiliency with Azure and .NET 8
Creating a scalable web app in Azure
Creating a scalable web app with .NET 8
Performance issues that need to be considered when programming in C#
String concatenation
Exceptions
Multithreading environments for better results – dos and don’ts
Usability – why inserting data takes too much time
Designing fast selection logic
Selecting from a huge number of items
Interoperability with .NET
Tip - Creating a service in Linux
Achieving security by design
List of practices for achieving a safe architecture
Authentication
Sensitive data
Web security
Summary
Questions
Further reading
3 Documenting Requirements
Before you begin: join our book community on Discord
Technical requirements
Introducing Azure DevOps
Managing system requirements in Azure DevOps
Azure DevOps repository
Package feeds
Test Plans
Pipelines
Usage
Introducing GitHub Projects
Summary
Questions
Further reading
4 Best Practices in Coding C# 12
Before you begin: join our book community on Discord
Technical requirements
The simpler your code, the better a programmer you are
Maintainability index
Cyclomatic complexity
Depth of inheritance
Class coupling
Number of lines of code
Using a version control system
Dealing with version control systems in teams
Writing safe code in C#
try-catch
try-finally and using
The IDisposable interface
.NET 8 tips and tricks for coding
Identifying well-written code
Understanding and applying tools that can evaluate C# code
Applying extension tools to analyze code
Applying SonarAnalyzer
Checking the final code after analysis
Summary
Questions
Further reading
5 Implementing Code Reusability in C# 12
Before you begin: join our book community on Discord
Technical requirements
Understanding the principles of code reusability
What code reuse is not
What code reuse is
Reusability in the development life cycle
Using .NET 8 for code reuse
Creating a reusable class library
How does C# deal with code reuse?
What if the code is not reusable?
I have my libraries. How do I promote them?
Summary
Questions
Further reading
6 Design Patterns and .NET 8 Implementation
Before you begin: join our book community on Discord
Technical requirements
Understanding design patterns and their purpose
Builder pattern
Factory pattern
Singleton pattern
Proxy pattern
Command pattern
Publisher/Subscriber pattern
Dependency Injection pattern
Understanding the available design patterns in .NET
Summary
Questions
Further reading
7 Understanding the Different Domains in Software Solutions
Before you begin: join our book community on Discord
Technical requirements
What are software domains?
Understanding domain-driven design
Entities and value objects
Classic Layers architecture
Layers and the Onion architecture
Aggregates
The repository and Unit of Work patterns
Classic repository pattern versus DDD aggregates.
Command Query Responsibility Segregation (CQRS) pattern
Command handlers and domain events
Event sourcing
Summary
Questions
Further reading
8 Understanding DevOps Principles and CI/CD
Before you begin: join our book community on Discord
Technical requirements
Describing DevOps
Understanding DevOps principles
Understanding CI/CD
Defining continuous integration
Understanding continuous delivery with Azure DevOps
CI/CD and GitHub
Understanding the risks and challenges when using CI/CD
Defining continuous feedback and the related DevOps tools
Understanding SaaS
Adapting your organization to a service scenario
Developing software in a service scenario
Technical implications of a service scenario
Deciding when to adopt a SaaS solution
Preparing a solution for a service scenario
Summary
Questions
Further reading
9 Testing Your Enterprise Application
Before you begin: join our book community on Discord
Technical
Understanding unit and integration tests
Automating unit and integration tests
Writing automated (unit and integration) tests
Acceptance tests: writing functional and performance tests
Understanding test-driven development
Functional tests
Behavior Driven Development (BDD)
Defining C# test projects in Visual Studio
Using the xUnit test framework
Advanced test preparation and tear-down scenarios
Mocking interfaces with Moq
Automating functional tests in C#
Testing the staging application
Testing the staging application with Selenium
Testing a controlled application
Recording tests with Selenium IDE
Summary
Questions
Further reading
10 Deciding on the Best Cloud-Based Solution
Before you begin: join our book community on Discord
Technical requirements
Different software deployment models
IaaS and Azure opportunities
PaaS – a world of opportunities for developers
SaaS – just sign in and get started!
Understanding what serverless means
Why are hybrid applications so useful in many cases?
Summary
Questions
Further reading
11 Applying a Microservice Architecture to Your Enterprise Application
Before you begin: join our book community on Discord
Technical requirements
What are microservices?
Microservices and the evolution of the concept of modules
Microservices design principles
Containers and Docker
When do microservices help?
Layered architectures and microservices
When is it worth considering microservice architectures?
How does .NET deal with microservices?
.NET communication facilities
Resilient task execution
Using generic hosts
Visual Studio support for Docker
Azure and Visual Studio support for microservice orchestration
Which tools are needed to manage microservices?
Defining your private Docker registry in Azure
Summary
Questions
Further reading
12 How to Choose Your Data Storage in the Cloud
Before you begin: join our book community on Discord
Technical requirements
Understanding the different repositories for different purposes
Relational databases
NoSQL databases
Redis
Azure storage accounts
Choosing between SQL or NoSQL document-oriented databases
Azure Cosmos DB – an opportunity to manage a multi-continental database
Creating an Azure Cosmos DB account
Creating an Azure Cosmos container
Accessing Azure Cosmos data
Defining database consistency
The Cosmos DB client
The Cosmos DB Entity Framework Core provider
Summary
Questions
Further reading
13 Interacting with Data in C# – Entity Framework Core
Before you begin: join our book community on Discord
Technical requirements
Understanding ORM basics
Configuring Entity Framework Core
Defining DB entities
Defining the mapped collections
Completing the mapping configuration
Entity Framework Core migrations
Understanding stored procedures and direct SQL commands
Compiled models
Querying and updating data with Entity Framework Core
Returning data to the presentation layer
Issuing direct SQL commands
Handling transactions
Deploying your data layer
How Data and Domain layers communicate with other layers.
Understanding Entity Framework Core advanced features
Summary
Questions
Further reading
14 Kubernetes
Before you begin: join our book community on Discord
Technical requirements
Kubernetes basics
.yaml files
ReplicaSets and Deployments
StatefulSets
Services
Ingresses
Interacting with a Kubernetes clusters
Creating an Azure Kubernetes Cluster
Using Minikube
Using Kubectl
Deploying the demo Guestbook application
Advanced Kubernetes concepts
Requiring permanent storage
Kubernetes secrets
Liveness and readiness checks
Autoscaling
Helm – Installing an Ingress Controller
Summary
Questions
Further reading
15 Implementing Microservices with .NET
Before you begin: join our book community on Discord
Technical requirements
Communication and data serialization
Efficient and flexible binary serialization
The ProtoBuf language
ProtoBuf serialization
Efficient and flexible RPC
Reliable data-driven asynchronous communication
Distributed transactions
Implementing worker microservices with ASP.NET core
Implementing microservices with .NET worker services and message brokers
Installing RabbitMQ
RabbitMQ basics
Replacing internal queues with RabbitMQ
Summary
Questions
Further reading
16 Applying Service-Oriented Architectures with .NET
Before you begin: join our book community on Discord
Technical requirements
Understanding the principles of the SOA approach
SOAP web services
SOAP specifications
Difficulties associated with the standard
REST web services
Service type compatibility rules
REST and native HTTP features
Example of methods in the REST language
The OpenAPI standard
REST service authorization and authentication
How does .NET 8 deal with SOA?
SOAP client support
gRPC support
A short introduction to ASP.NET Core
Implementing REST services with ASP.NET Core
Summary
Questions
Further reading
17 Working with Serverless
Before you begin: join our book community on Discord
Technical requirements
Understanding the Azure Functions app
Consumption plan
Premium plan
App Service plan
Programming Azure Functions using C#
Listing Azure Functions templates
Maintaining Azure Functions
Azure Durable Functions
Azure Functions roadmap
Summary
Questions
Further reading
18 Presenting ASP.NET Core
Before you begin: join our book community on Discord
Technical requirements
Understanding the presentation layers of web applications
Understanding the basics of ASP.NET Core
ASP.NET Core middleware
Loading configuration data and using it with the options framework
Defining the ASP.NET Core pipeline
Defining controllers and ViewModels
Understanding how ASP.NET Core MVC creates the response HTML
Razor Views
Reusing view code
Understanding the connection between ASP.NET Core MVC and design principles
Advantages of the ASP.NET Core pipeline
Server-side and client-side validation
ASP.NET Core globalization
The MVC pattern
Summary
Questions
Further reading
19 Implementing Frontend Microservices with ASP.NET Core
Before you begin: join our book community on Discord
Technical requirements
Frontends and micro-frontends
Public web APIs
HTML micro-frontends
Defining the application architecture
Defining the domain layer abstraction
Defining the data layer
Defining the application layer
Defining controllers
Summary
Further reading
20 Client Frameworks: Blazor
Before you begin: join our book community on Discord
Technical requirements
Comparison of the various types of client technologies
Single Page Applications
Progressive Applications
Native Applications
Cross-platform Applications
Blazor WebAssembly architecture
What is a single-page application?
Loading and starting the application
Routing
Blazor pages and components
Component structure
Templates and cascading parameters
Error handling
Events
Bindings
How Blazor updates HTML
Component lifecycle
Blazor forms and validation
Modifying HTML content from Blazor components
Blazor advanced features
References to components and HTML elements
JavaScript interoperability
Globalization and localization
Authentication and authorization
Communication with the server
AOT compilation
Third-party tools for Blazor WebAssembly
.NET MAUI Blazor
What is .NET MAUI ?
Developing native applications with Blazor
Summary
Questions
Further reading
21 Case Study
Before you begin: join our book community on Discord
Introducing World Wild Travel Club
User needs and system requirements
Main types of .NET projects used at WWTravelClub
Managing WWTravelClub requirements using Azure DevOps
Code Standard for WWTravelClub - DOs and DON’Ts in writing code
Applying Sonar Cloud at WWTravelClub API’s
Reusing code as a fast way to deliver good and safe software
Understanding the domains of the WWTravelClub application
The WWTravelClub DevOps approach
How to Choose Your Data Storage in the Cloud
Implementing the destinations/packages database with Cosmos DB
A worker microservices with ASP.NET core
The problem and the architecture
The storage layer
The application layer
Processing the queued requests
Testing the GrpcMicroservice project with a fake purchase requests generator
A worker microservice based on RabbitMQ
Exposing WWTravelClub packages using Web API’s
Implementing Azure Functions to send e-mails
First step – Creating Azure queue storage
Second step – Creating the function to send e-mails
Third step – Creating the queue trigger function
A Frontend Microservice
Defining application specifications
Defining the application architecture
Defining the domain layer abstraction
Defining the data layer
Defining the application layer
Defining controllers and views
Using Client Technologies
Preparing the solution
Implementing the required ASP.NET Core REST APIs
Implementing the business logic in a service
Implementing the user interface
Adding a Blazor MAUI Version
Testing the WWTravelClub application
Connecting to an Azure DevOps repository
Summary