Hands-On Software Architecture with C# 8 and .NET Core 3

Book description

Design scalable and high-performance enterprise applications using the latest features of C# 8 and .NET Core 3

Key Features

  • Become a software architect capable of creating modular apps for specific business needs
  • Design high-performance software systems using the latest features of C# 8 and .NET Core 3
  • Solve scalability problems in web apps using enterprise architectural patterns

Book Description

Software architecture is the practice of implementing structures and systems that streamline the software development process and improve the quality of an app. With this software architecture book, you'll follow a hands-on approach to learning various architectural methods that will help you develop and deliver high-quality products.

You'll begin by understanding how to transform user requirements into architectural needs and exploring the differences between functional and non-functional requirements. Next, you'll explore how to carefully choose a cloud solution for your infrastructure, along with covering dos and don'ts that will help you manage your app in a cloud-based environment. Later chapters will cover techniques and processes such as DevOps, microservices, and continuous integration, along with providing insights into implementing them using Microsoft technologies such as ASP.NET Core, the Entity Framework, Cosmos DB, and Azure DevOps. You will also learn about testing frameworks and automation tools that will help you through the development process. Finally, you'll discover design patterns and various software approaches that will allow you to solve common problems faced during development.

By the end of this book, you'll be able to develop and deliver highly scalable enterprise-ready apps that meet customers' business needs.

What you will learn

  • Overcome real-world architectural challenges and solve design consideration issues
  • Apply architectural approaches like Layered Architecture, service-oriented architecture (SOA), and microservices
  • Learn to use tools like containers, Docker, and Kubernetes to manage microservices
  • Get up to speed with Azure Cosmos DB for delivering multi-continental solutions
  • Learn how to program and maintain Azure Functions using C#
  • Understand when to use test-driven development (TDD) as an approach for software development
  • Write automated functional test cases for your projects

Who this book is for

This book is for engineers and senior developers aspiring to become architects or looking to build enterprise applications with the .NET Stack. Experience with C# and .NET is required to understand this book.

Publisher resources

Download Example Code

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. Hands-On Software Architecture with C# 8 and .NET Core 3
  3. About Packt
    1. Why subscribe?
  4. Contributors
    1. About the authors
    2. About the reviewers
    3. Packt is searching for authors like you
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Code in Action
      3. Download the color images
      4. Conventions used
    4. Get in touch
      1. Reviews
  6. Section 1: Transforming Customer Needs in Real-World Applications
  7. Understanding the Importance of Software Architecture
    1. Technical requirements
    2. What is software architecture?
      1. Creating an Azure account
    3. Software development process models
      1. Reviewing traditional software development process models
        1. Understanding the waterfall model principles
        2. Analyzing the incremental model
      2. Understanding agile software development process models
        1. Getting into the Scrum model
    4. Enabling aspects to be gathered to design high-quality software
      1. Understanding the requirements gathering process
        1. Practicing the elicitation of user needs
        2. Analyzing requirements
        3. Writing the specifications
        4. Reviewing the specification
    5. Using design thinking as a helpful tool
      1. Understanding the principles of scalability, robustness, security, and performance
    6. Some cases where the requirements gathering process impacted system results
      1. Case 1 – my website is too slow to open that page!
        1. Understanding caching
        2. Applying asynchronous programming
        3. Dealing with object allocation
        4. Getting better database access
      2. Case 2 – the user's needs are not properly implemented
      3. Case 3 – the usability of the system does not meet user needs
    7. Case study – detecting user needs
      1. Book case study – introducing World Wild Travel Club
      2. Book case study – understanding user needs and system requirements
    8. Summary
    9. Questions
    10. Further reading
  8. Functional and Nonfunctional Requirements
    1. Technical requirements
    2. How does scalability interact with Azure and .NET Core?
      1. Creating a scalable web app in Azure
        1. Vertical scaling (Scale up)
        2. Horizontal scaling (Scale out)
      2. Creating a scalable web app with .NET Core
    3. Performance issues that need to be considered when programming in C#
      1. String concatenation
      2. Exceptions
    4. Multithreading environments for better results – do's and don'ts
    5. Usability – why inserting data takes too much time
      1. Designing fast selection logic
      2. Selecting from a huge amount of items
    6. The fantastic world of interoperability with .NET Core
      1. Creating a service in Linux
    7. Book use case – understanding the main types of .NET Core projects
    8. Summary
    9. Questions
    10. Further reading
  9. Documenting Requirements with Azure DevOps
    1. Technical requirements
    2. Introducing Azure DevOps
    3. Organizing your work using Azure DevOps
      1. Azure DevOps repository
      2. Package feeds
      3. Test plans
      4. Pipelines
    4. Managing system requirements in Azure DevOps
      1. Epics work items
      2. Features work items
      3. Product Backlog items/User Story work items
    5. Book use case – presenting use cases in Azure DevOps
    6. Summary
    7. Questions
    8. Further reading
  10. Section 2: Architecting Software Solutions in a Cloud-Based Environment
  11. Deciding the Best Cloud-Based Solution
    1. Technical requirements
    2. Different software deployment models
    3. Infrastructure as a service and Azure opportunities
      1. Security responsibility in IaaS
    4. PaaS – a world of opportunities for developers
      1. Web apps
      2. Azure SQL Server
      3. Azure Cognitive Services
    5. SaaS – just sign in and get started!
    6. Understanding what serverless means
    7. Why are hybrid applications so useful in many cases?
    8. Use case – a hybrid application
      1. Book use case – which is the best cloud platform for this use case?
    9. Summary
    10. Questions
    11. Further reading
  12. Applying a Microservice Architecture to Your Enterprise Application
    1. Technical requirements
    2. What are microservices?
      1. Microservices and the evolution of the concept of modules
      2. Microservice design principles
      3. Containers and Docker
    3. When do microservices help?
      1. Layered architectures and microservices
      2. When is it worth considering microservice architectures?
    4. How does .NET Core deal with microservices?
      1. .NET Core communication facilities
      2. Resilient task execution
      3. Using generic hosts
      4. Visual Studio support for Docker
      5. Azure and Visual Studio support for microservice orchestration
    5. Which tools are needed to manage microservices?
      1. Defining your private Docker registry in Azure
      2. Azure Service Fabric
        1. Step 1: Basic information
        2. Step 2: Cluster configuration
        3. Step 3: Security configuration
      3. Azure Kubernetes Service (AKS)
    6. Use case – logging microservices
      1. Ensuring message idempotency
      2. The Interaction library
      3. Implementing the receiving side of communication
      4. Implementing service logic
      5. Defining the microservice's host
      6. Communicating with the service
      7. Testing the application
    7. Summary
    8. Questions
    9. Further reading
  13. Interacting with Data in C# - Entity Framework Core
    1. Technical requirements
    2. Understanding ORM basics
    3. Configuring Entity Framework Core
      1. Defining DB entities
      2. Defining the mapped collections
      3. Completing the mapping configuration
    4. Entity Framework Core migrations
      1. Understanding stored procedures and direct SQL commands
    5. Querying and updating data with Entity Framework Core
      1. Returning data to the presentation layer
      2. Issuing direct SQL commands
      3. Handling transactions
    6. Deploying your data layer
    7. Understanding Entity Framework Core advanced feature – global filters
    8. Summary
    9. Questions
    10. Further reading
  14. How to Choose Your Data Storage in the Cloud
    1. Technical requirements
    2. Understanding the different repositories for different purposes
      1. Relational databases
      2. NoSQL databases
      3. Redis
      4. Disk memory
    3. Choosing between structured or NoSQL storage
    4. Azure Cosmos DB – an opportunity to manage a multi-continental database
      1. Cosmos DB client
      2. Cosmos DB Entity Framework Core provider
    5. Use case – storing data
      1. Implementing the destinations/packages database with Cosmos DB
    6. Summary
    7. Questions
    8. Further reading
  15. Working with Azure Functions
    1. Technical requirements
    2. Understanding the Azure Functions App
      1. Consumption Plan
      2. App Service Plan
    3. Programming Azure Functions using C#
      1. Listing Azure Functions templates
    4. Maintaining Azure Functions
    5. Use case – implementing Azure Functions to send emails
      1. First Step – creating Azure Queue Storage
    6. Summary
    7. Questions
    8. Further reading
  16. Section 3: Applying Design Principles for Software Delivered in the 21st Century
  17. Design Patterns and .NET Core Implementation
    1. Technical requirements
    2. Understanding design patterns and their purpose
      1. Builder pattern
      2. Factory pattern
      3. Singleton pattern
      4. Proxy pattern
      5. Command pattern
      6. Publisher/Subscriber pattern
      7. Dependency Injection pattern
    3. Understanding the available design patterns in .NET Core
    4. Summary
    5. Questions
    6. Further reading
  18. Understanding the Different Domains in Software Solutions
    1. Technical requirements
    2. What are software domains?
    3. Understanding domain-driven design
      1. Entities and value objects
    4. Using SOLID principles to map your domains
      1. Aggregates
      2. The repository and Unit of Work patterns
      3. DDD entities and Entity Framework Core
      4. Command Query Responsibility Segregation (CQRS) pattern
      5. Command handlers and domain events
      6. Event sourcing
    5. Use case – understanding the domains of the use case
    6. Summary
    7. Questions
    8. Further reading
  19. Implementing Code Reusability in C# 8
    1. Technical requirements
    2. Understanding the principles of code reusability
      1. What is not code reuse?
      2. What is code reuse?
      3. Inserting reusability into your development cycle
    3. Using .NET Standard for code reuse
      1. Creating a .NET Standard library
    4. How does C# deal with code reuse?
      1. Object-oriented analysis
      2. Generics
    5. Use case – reusing code as a fast track to deliver good and safe software
    6. Summary
    7. Questions
    8. Further reading
  20. Applying Service-Oriented Architectures with .NET Core
    1. Technical requirements
    2. Understanding the principles of the SOA approach
      1. SOAP web services
      2. REST web services
        1. The OpenAPI standard
        2. REST services authorization and authentication
    3. How does .NET Core deal with SOA?
      1. A short introduction to ASP.NET Core
      2. Implementing REST services with ASP.NET Core
      3. ASP.NET Core service authorization
      4. ASP.NET Core support for OpenAPI
      5. .Net Core HTTP clients
    4. Use case – exposing WWTravelClub packages
    5. Summary
    6. Questions
    7. Further reading
  21. Presenting ASP.NET Core MVC
    1. Technical requirements
    2. Understanding the presentation layers of web applications
    3. Understanding the ASP.NET Core MVC structure
      1. How ASP.NET Core pipeline works
      2. Loading configuration data and using it with the options framework
      3. Defining the ASP.NET Core MVC pipeline
      4. Defining controllers and ViewModels
      5. Understanding Razor Views
        1. Learning Razor flow of control statements
        2. Understanding Razor View properties
        3. Using Razor tag helpers
        4. Reusing view code
    4. What is new in .NET Core 3.0 for ASP.NET Core?
    5. Understanding the connection between ASP.NET Core MVC and design principles
      1. Advantages of the ASP.NET Core pipeline
      2. Server-side and client-side validation
      3. ASP.NET Core globalization
      4. The MVC pattern
    6. Use case – implementing a web app in ASP.NET Core MVC
      1. Defining application specifications
      2. Defining the application architecture
      3. Defining the domain layer
      4. Defining the data layer
      5. Defining the application layer
      6. Controllers and views
    7. Summary
    8. Questions
    9. Further reading
  22. Section 4: Programming Solutions for an Unavoidable Future Evolution
  23. Best Practices in Coding C# 8
    1. Technical requirements
    2. The more complex your code is, the worse a programmer you are
      1. Maintainability index
      2. Cyclomatic complexity
      3. Depth of inheritance
      4. Class coupling
      5. Lines of code
    3. Using a version control system
      1. Dealing with version control systems in teams
    4. Writing safe code in C#
      1. try-catch
      2. try-finally and using
      3. The IDisposable interface
    5. .NET Core tips and tricks for coding
    6. WWTravelClub – dos and don'ts in writing code
    7. Summary
    8. Questions
    9. Further reading
  24. Testing Your Code with Unit Test Cases and TDD
    1. Technical requirements
    2. Understanding automated tests
      1. Writing automated (unit and integration) tests
      2. Writing acceptance and performance tests
    3. Understanding test-driven development (TDD)
    4. Defining C# test projects
      1. Using the xUnit test framework
      2. Advanced test preparation and tear-down scenarios
      3. Mocking interfaces with Moq
    5. Use case – automating unit tests in DevOps Azure
    6. Summary
    7. Questions
    8. Further reading
  25. Using Tools to Write Better Code
    1. Technical requirements
    2. Identifying a well-written code
    3. Understanding and applying tools that can evaluate C# code
      1. Applying extension tools to analyze code
        1. Using Microsoft Code Analysis 2019
        2. Applying SonarLint for Visual Studio 2019
        3. Getting Code Cracker for Visual Studio 2017 as a helper to write better code
        4. Checking the final code after analysis
    4. Use case – evaluating the C# code before publishing the application
    5. Summary
    6. Questions
    7. Further reading
  26. Section 5: Delivering Software Continuously and at a High Quality Level
  27. Deploying Your Application with Azure DevOps
    1. Technical requirements
    2. Understanding SaaS
      1. Adapting your organization to a service scenario
      2. Developing software in a service scenario
      3. Technical implications of a service scenario
      4. Adopting a SaaS solution
    3. Preparing a solution for a service scenario
    4. Use case – deploying our package-management application with Azure Pipelines
      1. Creating the Azure Web App and the Azure database
      2. Configuring your Visual Studio solution
      3. Configuring Azure Pipelines
      4. Adding a manual approval for the release
      5. Creating a release
    5. Summary
    6. Questions
    7. Further reading
  28. Understanding DevOps Principles
    1. Technical requirements
    2. Describing DevOps
    3. Understanding DevOps principles
      1. Defining continuous integration
      2. Understanding continuous delivery and multistage environment with Azure DevOps
      3. Defining continuous feedback and the related DevOps tools 
        1. Monitoring you software with Application Insights
        2. Using the Test and Feedback tool to enable feedback
    4. The WWTravelClub project approach
    5. Summary
    6. Questions
    7. Further Reading
  29. Challenges of Applying CI Scenarios in DevOps
    1. Technical requirements
    2. Understanding CI
    3. Understanding the risks and challenges when using CI
      1. Disabling continuous production deployment
      2. Incomplete features
      3. Unstable solution for testing
    4. Understanding the WWTravelClub project approach
    5. Summary
    6. Questions
    7. Further reading
  30. Automation for Software Testing
    1. Technical requirements
    2. Understanding the purpose of functional tests
    3. Using unit testing tools to automate functional tests in C#
      1. Testing the staging application
      2. Testing a controlled application
    4. Use case – automating functional tests
    5. Summary
    6. Questions
    7. Further reading
  31. Assessments
    1. Chapter 1
    2. Chapter 2
    3. Chapter 3
    4. Chapter 4
    5. Chapter 5
    6. Chapter 6
    7. Chapter 7
    8. Chapter 8
    9. Chapter 9
    10. Chapter 10
    11. Chapter 11
    12. Chapter 12
    13. Chapter 13
    14. Chapter 14
    15. Chapter 15
    16. Chapter 16
    17. Chapter 17
    18. Chapter 18
    19. Chapter 19
    20. Chapter 20
  32. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Hands-On Software Architecture with C# 8 and .NET Core 3
  • Author(s): Gabriel Baptista, Francesco Abbruzzese
  • Release date: November 2019
  • Publisher(s): Packt Publishing
  • ISBN: 9781789800937