Home Programming Software Architecture with C# 9 and .NET 5 - Second Edition

Software Architecture with C# 9 and .NET 5 - Second Edition

By Gabriel Baptista , Francesco Abbruzzese
books-svg-icon Book
eBook $61.99 $42.99
Print $76.99
Subscription $15.99 $10 p/m for three months
$10 p/m for first 3 months. $15.99 p/m after that. Cancel Anytime!
What do you get with a Packt Subscription?
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats, plus a monthly download credit
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do you get with video?
Download this video in MP4 format
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with video?
Stream this video
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with Audiobook?
Download a zip folder consisting of audio files (in MP3 Format) along with supplementary PDF
What do you get with Exam Trainer?
Flashcards, Mock exams, Exam Tips, Practice Questions
Access these resources with our interactive certification platform
Mobile compatible-Practice whenever, wherever, however you want
BUY NOW $10 p/m for first 3 months. $15.99 p/m after that. Cancel Anytime!
eBook $61.99 $42.99
Print $76.99
Subscription $15.99 $10 p/m for three months
What do you get with a Packt Subscription?
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats, plus a monthly download credit
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do you get with video?
Download this video in MP4 format
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with video?
Stream this video
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with Audiobook?
Download a zip folder consisting of audio files (in MP3 Format) along with supplementary PDF
What do you get with Exam Trainer?
Flashcards, Mock exams, Exam Tips, Practice Questions
Access these resources with our interactive certification platform
Mobile compatible-Practice whenever, wherever, however you want
  1. Free Chapter
    Non-Functional Requirements
About this book
Software architecture is the practice of implementing structures and systems that streamline the software development process and improve the quality of an app. This fully revised and expanded second edition, featuring the latest features of .NET 5 and C# 9, enables you to acquire the key skills, knowledge, and best practices required to become an effective software architect. This second edition features additional explanation of the principles of Software architecture, including new chapters on Azure Service Fabric, Kubernetes, and Blazor. It also includes more discussion on security, microservices, and DevOps, including GitHub deployments for the software development cycle. You will begin by understanding how to transform user requirements into architectural needs and exploring the differences between functional and non-functional requirements. Next, you will explore how to carefully choose a cloud solution for your infrastructure, along with the factors that will help you manage your app in a cloud-based environment. Finally, you will discover software design patterns and various software approaches that will allow you to solve common problems faced during development. By the end of this book, you will be able to build and deliver highly scalable enterprise-ready apps that meet your organization’s business requirements.
Publication date:
December 2020
Publisher
Packt
Pages
700
ISBN
9781800566040

 

Non-Functional Requirements

Once you have gathered the system requirements, it is time to think about the impact they have on the architectural design. Scalability, availability, resiliency, performance, multithreading, interoperability, security, and other subjects need to be analyzed so that we can meet user needs. We refer to these aspects as non-functional requirements.

The following topics will be covered in this chapter:

  • How do .NET 5 and Azure enable scalability, availability, and resiliency?
  • Performance issues that need to be considered when programming in C#
  • Software usability, that is, how to design effective user interfaces
  • .NET 5 and interoperability
  • Achieving security by design
  • Book use case – understanding the main types of .NET Core projects
 

Technical requirements

The samples provided in this chapter will require Visual Studio 2019 Community Edition with .NET 5 SDK installed.

You can find the sample code for this chapter at https://github.com/PacktPublishing/Software-Architecture-with-C-9-and-.NET-5.

 

Enabling scalability, availability, and resiliency with Azure and .NET 5

A short search on scalability returns a definition such as the ability of a system to keep working well when there is an increase in demand. Once developers read this, many of them incorrectly conclude that scalability only means adding more hardware to keep things working without stopping the app.

Scalability relies on technologies involving hardware solutions. However, as a software architect, you must be aware that good software will keep scalability in a sustainable model, which means that a well-architected software can save a lot of money. Hence, it is not just a matter of hardware but also a matter of overall software design. The point here is that the running cost of a system should also be a factor in the architectural decisions.

In Chapter 1, Understanding the Importance of Software Architecture, while discussing software performance, we proposed some good tips to overcome bad performance issues...

 

Performance issues that need to be considered when programming in C#

Nowadays, C# is one of the most commonly used programming languages all over the world, so good tips about C# programming are fundamental for the design of good architectures that satisfy the most common non-functional requirements.

The following sections mention a few simple but effective tips – the associated code samples are available in the GitHub repository of this book.

String concatenation

This is a classic one! A naive concatenation of strings with the + string operator may cause serious performance issues since each time two strings are concatenated, their contents are copied into a new string.

So, if we concatenate, for instance, 10 strings that have an average length of 100, the first operation has a cost of 200, the second one has a cost of 200+100=300, the third one has a cost of 300+100=400, and so on. It is not difficult to convince yourself that the overall cost grows like m...

 

Usability – why inserting data takes too much time

Scalability, performance tips, and multithreading are the main tools we can use to tune machine performance. However, the effectiveness of the system you design depends on the overall performance of the whole processing pipeline, which includes both humans and machines.

As a software architect, you cannot improve the performance of humans, but you can improve the performance of man-machine interaction by designing an effective user interface (UI), that is, a user interface that ensures fast interaction with humans, which, in turn, means the following:

  • The UI must be easy to learn in order to reduce the time that is needed for learning and time wasting before the target users learn to operate it quickly. This constraint is fundamental if UI changes are frequent, and for public websites that need to attract the greatest possible number of users.
  • The UI must not cause any kind of slowdown in data insertion...
 

The fantastic world of interoperability with .NET Core

.NET Core brought Windows developers the ability to deliver their software into various platforms. And you, as a software architect, need to pay attention to this. Linux and macOS are no longer a problem for a C# lover – it is much better than that – they are great opportunities to deliver to new customers. Therefore, we need to ensure performance and multi-platform support, two common non-functional requirements in several systems.

Both console applications and web apps designed with .NET Core in Windows are almost completely compatible with Linux and macOS, too. This means you do not have to build the app again to run it on these platforms. Also, very platform-specific behaviors now have multi-platform support, as shown, for instance, by the System.IO.Ports.SerialPort class, which, starting from .NET Core 3.0, is on Linux.

Microsoft offers scripts to help you install .NET Core on Linux and macOS. You can...

 

Achieving security by design

As we have seen up to here in the book, the opportunities and techniques we have for developing software are incredible. If you add all the information you will read about in relation to cloud computing in the next chapters, you will see that the opportunities just increase, as does the complexity to maintain all of this computing environment.

As a software architect, you must understand that these opportunities come with many responsibilities. The world has changed a lot in the last years. The second decade of the 21st century has required lots of technology. Apps, social media, Industry 4.0, Big Data, and artificial intelligence are no longer future objectives, but mainly current projects that you will lead and deal with in your routine.

Considering this scenario, security must have a different approach. The world has moved to regulate companies that manage personal data. For instance, GDPR – the General Data Protection Regulation –...

 

Book use case – understanding the main types of .NET Core projects

The development of this book's use case will be based on various kinds of .NET Core Visual Studio projects. This section describes all of them. Let us select New project in the Visual Studio File menu.

You can filter .NET Core project types by typing in the search engine, as follows:

Figure 2.19: Searching types of .NET Core projects in Visual Studio

There, you will find common C# projects (console, a class library, Windows Form, WPF), and various types of test projects, each based on a different test framework: xUnit, NUnit, and MSTest. Choosing among the various testing frameworks is just a matter of preference since all of them offer comparable features. Adding tests to each piece of software that composes a solution is a common practice and allows software to be modified frequently without jeopardizing its reliability.

You may also want to define your class library projects under...

 

Summary

Functional requirements that describe system behavior must be completed with non-functional requirements that constrain system performance, scalability, availability, resilience, interoperability, usability, and security.

Performance requirements come from response time and system load requirements. As a software architect, you should ensure you have the required performance at the minimum cost, building efficient algorithms and taking full advantage of the available hardware resources with multithreading.

Scalability is the ability of a system to be adapted to an increasing load. Systems can be scaled vertically by providing more powerful hardware, or horizontally by replicating and load balancing the same hardware, which increases the availability. The cloud, in general, and Azure can help us implement strategies dynamically, with no need to stop your application.

Tools such as .NET Core that run on several platforms can ensure interoperability, that is, the...

 

Questions

  1. Which are the two conceptual ways to scale a system?
  2. Can you deploy your web app automatically from Visual Studio to Azure?
  3. What is multithreading useful for?
  4. What are the main advantages of the asynchronous pattern over other multithreading techniques?
  5. Why is the order of input fields so important?
  6. Why is the .NET Core Path class so important for interoperability?
  7. What is the advantage of a .NET standard class library over a .NET Core class library?
  8. List the various types of .NET Core Visual Studio projects.
 
About the Authors
  • Gabriel Baptista

    Gabriel Baptista has been working with software development since the beginning of .NET. Today, his main contributions are managing numerous projects for retail and industry. He is an Azure Platform-as-a-Service (PaaS) solution specialist, teaches at Computing Engineering universities, and helps tech startups as a mentor.

    Browse publications by this author
  • Francesco Abbruzzese

    Francesco Abbruzzese dedicates his life to his two great passions: software and powerlifting. He is the author of the MVC Controls Toolkit and the Blazor Controls Toolkit libraries. He has contributed to the diffusion and evangelization of the Microsoft web stack since the first version of ASP.NET. His company, Mvcct Team, offers web applications, tools, and services for web technologies. He has moved from AI systems, where he implemented one of the first decision support systems for financial institutions, to top-10 video game titles such as Puma Street Soccer.

    Browse publications by this author
Latest Reviews (2 reviews total)
Bom material editorial. Boa qualidade gráfica.
Very comprehensive book covering a wide range of topics in the new .NET universe.
Software Architecture with C# 9 and .NET 5 - Second Edition
Unlock this book and the full library FREE for 7 days
Start now