title
stringlengths
3
46
content
stringlengths
0
1.6k
1:215
Create a glossary to make understanding easier.
1:216
Describe the kind of user the solution will cover.
1:217
1:218
1:219
Write functional and non-functional requirements:
1:220
Functional requirements are quite simple to understand because they describe exactly what the software will do. On the other hand, non-functional requirements determine the restrictions related to the software, which means scalability, robustness, security, and performance. We will cover these aspects in the next section.
1:221
1:222
1:223
Attach documents that can help the user to understand the rules.
1:224
1:225
If you decide to write user stories, a good tip to follow is to write short sentences representing each moment in the system with each user, as follows:
1:226
As <user>, I want <feature>, so that <reason>
1:227
This approach will explain exactly the reason why that feature will be implemented. It is also a good tool to help you analyze the stories that are most important and prioritize the success of the project. They can also be great for informing the automated acceptance tests that should be built.
1:228
Understanding the principles of scalability, robustness, security, and performance
1:229
Detecting requirements is a task that will let you understand the software you are going to develop. However, as a software architect, you must pay attention to more than just the functional requirements for that system. Understanding the non-functional requirements is important, and one of the earliest activities for a software architect.
1:230
We are going to look at this in more detail in Chapter 2, Non-Functional Requirements, but at this point, it is important to know that the principles of scalability, robustness, security, and performance need to be applied to the requirements gathering process. Let us look at each concept:
1:231
1:232
Scalability: The Internet gives you the opportunity to have a solution with a great number of users all over the world. This is fantastic, but you, as a software architect, need to design a solution that provides that possibility. Scalability is the possibility for an application to increase its processing power as soon as it is necessary, due to the number of resources that are being consumed.
1:233
Robustness: No matter how scalable your application is, if it is not able to guarantee a stable and always-on solution, you are not going to get any peace. Robustness is important for critical solutions, where you do not have the opportunity to carry out maintenance at any time due to the kind of problem that the application solves. In many industries, the software cannot stop, and lots of routines run when nobody is available (overnight, during holidays, and so on). Designing a reliable solution will free you up to live your life while your software is running smoothly.
1:234
Security: This is another really important area that needs to be discussed after the requirements stage. Everybody worries about security, and different laws dealing with it are in place in different parts of the world. You, as a software architect, must understand that security needs to be provided by design. This is the only way to cope with all the needs that the security community is discussing right now.
1:235
Performance: The process of understanding the system you are going to develop will probably give you a good idea of what you will need to do to get the desired performance from the system. This topic needs to be discussed with the user, to identify most of the bottlenecks you will face during the development stage.
1:236
1:237
It is worth mentioning that all these concepts are requirements for the new generation of solutions that the world needs. What differentiates good software from incredible software is the amount of work done to meet the project requirements.
1:238
Reviewing the specification
1:239
Once you have the specification written, it is time to confirm with the stakeholders whether they agree with it. This can be done in a review meeting, or it can be done online using collaboration tools.
1:240
This is when you present all the prototypes, documents, and information you have gathered. As soon as everybody agrees with the specification, you are ready to start studying the best way to implement this part of your project.
1:241
It is worth mentioning that you might use the process described here for either the complete software or for just a small part of it.
1:242
Using design techniques as a helpful tool
1:243
Defining a solution is not easy. Determining which technology to use is also difficult. It is true that, during your career as a software architect, you will find many projects where your customer will bring you a solution ready for development. This can get quite complicated if you consider that solution as the correct solution; most of the time, there will be architectural and functional mistakes that will cause problems in the solution in the future.
1:244
There are some cases where the problem is worse – when the customer does not know the best solution for the problem. Some design techniques can help us with this, and we will introduce two of them here: Design Thinking and Design Sprint.
1:245
What you must understand is that these techniques can be a fantastic option to discover real requirements. As a software architect, you are committed to helping your team to use the correct tools at the correct time, and these tools may be the right options to ensure the project’s success.
1:246
Design Thinking
1:247
Design Thinking is a process that allows you to collect data directly from the users, focusing on achieving the best results to solve a problem. During this process, the team will have the opportunity to discover all the personas that will interact with the system. This will have a wonderful impact on the solution since you can develop the software by focusing on the user experience, which can have a fantastic impact on the results.
1:248
The process is based on the following steps:
1:249
1:250
Empathize: In this step, you must execute field research to discover users’ concerns. This is where you find out about the users of the system. The process is good for making you understand why and for whom you are developing this software.
1:251
Define: Once you have the users’ concerns, it is time to define their needs to solve them.
1:252
Ideate: The needs will provide an opportunity to brainstorm some possible solutions.
1:253
Prototype: These solutions can be developed as mock-ups to confirm whether they are good ones.
1:254
Test: Testing the prototypes will help you to understand the prototype that is most connected to the real needs of the users.
1:255
1:256
The focus of a technique like this one is to accelerate the process of discerning the right product and considering the Minimum Viable Product (MVP). For sure, the prototype process will help stakeholders to understand the final product and, at the same time, engage the team to deliver the best solution.
1:257
Design Sprint
1:258
Design Sprint is a process focused on solving critical business questions through design in a five-day sprint. This technique was presented by Google, and it is something that allows you to quickly test and learn from an idea when you are looking to build and launch a solution to market.
1:259
The process involves experts spending a week to solve the problem at hand, in a war room prepared for that purpose. The week looks like this:
1:260
1:261
Monday: The focus of this day is to identify the target of the sprint and map the challenge to achieve it.
1:262
Tuesday: After understanding the goal of the sprint, participants start sketching solutions that may solve it. It is time to find customers to test the new solution that will be provided.
1:263
Wednesday: This is when the team needs to decide on the solutions that have the greatest chance of solving the problem. The team must draw these solutions into a storyboard, preparing a plan for the prototype.
1:264
Thursday: It is time to prototype the idea planned on the storyboard.
1:265
Friday: Having completed the prototype, the team presents it to customers, learning by getting information from their reactions to the solution designed.
1:266
1:267
As you can see, in both techniques, the acceleration of collecting reactions from customers comes from prototypes that will materialize your team’s ideas into something more tangible for the end user.
1:268
Common cases where the requirements gathering process impacts system results
1:269
All the information discussed up to this point in the chapter is useful if you want to design software following the principles of good engineering. Rather than advocating for traditional or agile development methods, the emphasis is on building software in a professional manner.
1:270
It is also a good idea to know about some cases in which failing to perform the activities you read about can cause some trouble for a software project. The following cases intend to describe what can go wrong, and how the preceding techniques can help a development team to solve the associated problems.
1:271
In most cases, very simple actions can guarantee better communication between the team and the customer, and this easy communication flow can transform a big problem into a real solution. Let us examine three common cases where requirements gathering can impact software performance, functionality, and usability.
1:272
Case 1 – my website is too slow to open that page!
1:273
Performance is one of the biggest problems that you as a software architect will deal with during your career. The reason why this aspect of any software is so problematic is that we do not have infinite computational resources to solve problems. The cost of computation is still high, especially if you are talking about software with a high number of simultaneous users.
1:274
You cannot solve performance problems by writing requirements. However, you will not end up in trouble if you write them correctly. The idea here is that requirements must present the desired performance of a system. A simple sentence describing this can help the entire team that works on the project:
1:275
Non-functional requirement: Performance – any web page of this software shall respond in at least 2 seconds, even when 1,000 users are accessing it concurrently.
1:276
The preceding sentence just lets everybody (users, testers, developers, architects, managers, and so on) know that any web page has a target to achieve. This is a good start, but it is not enough. A great environment for developing and deploying your application is also important. This is where .NET 8 can help you a lot; especially if you are talking about web apps, ASP.NET Core is considered one of the fastest options to deliver solutions today.
1:277
When it comes to performance, you, as a software architect, should consider the use of the techniques listed in the following sections together with specific tests to guarantee this non-functional requirement. It is also important to mention that ASP.NET Core will help you to use them easily, together with some Platform as a Service (PaaS) solutions delivered by Microsoft Azure.
1:278
Understanding backend caching
1:279
Caching is a great technique to avoid time-consuming and redundant queries. For instance, if you are fetching car models from a database, the number of cars in the database can increase, but the models themselves will not change. Once you have an application that constantly accesses car models, a good practice is to cache that information.
1:280
It is important to understand that a cache is stored in the backend and that cache is shared by the whole application (in-memory caching). A point to focus on is that when you are working on a scalable solution, you can configure a distributed cache using the Azure platform. In fact, ASP.NET provides both in-memory caching and distributed caching, so you can decide on the one that best fits your needs. Chapter 2, Non-Functional Requirements, covers scalability aspects in the Azure platform.
1:281
It is also important to mention that caching can happen in the frontend, in proxies along the way to the server, CDNs, and so on.
1:282
Applying asynchronous programming
1:283
When you develop ASP.NET applications, you need to keep in mind that your app needs to be designed for simultaneous access by many users. Asynchronous programming lets you do this simply, by giving you the keywords async and await.
1:284
The basic concept behind these keywords is that async enables any method to run asynchronously. On the other hand, await lets you synchronize the call of an asynchronous method without blocking the thread that is calling it. This easy-to-develop pattern will make your application run without performance bottlenecks and bring better responsiveness. This book will cover more about this subject in Chapter 2, Non-Functional Requirements.
1:285
Dealing with object allocation
1:286
One very good tip to avoid poor performance is to understand how the Garbage Collector (GC) works. The GC is the engine that will free memory automatically when you finish using it. There are some very important aspects of this topic, due to the complexity that the GC has.
1:287
Some types of objects are not collected by the GC if you do not dispose of them. The list includes any object that interacts with I/O, such as files and streaming. If you do not correctly use the C# syntax to create and destroy this kind of object, you will have memory leaks, which will deteriorate your application’s performance.
1:288
The incorrect way of working with I/O objects is:
1:289
System.IO.StreamWriter file = new System.IO.StreamWriter(@`C:sample.txt`);
1:290
file.WriteLine(`Just writing a simple line`);
1:291
1:292
The correct way of working with I/O objects is:
1:293
using System.IO.StreamWriter file = new System.IO.StreamWriter(@`C:sample.txt`);
1:294
file.WriteLine(`Just writing a simple line`);
1:295
1:296
It might be worth noting that this correct approach also ensures the file gets written (it calls FileStream.Flush() to dispose of its resources gracefully). In the incorrect example, the contents might not even be written to the file. Even though the preceding practice is mandatory for I/O objects, it is totally recommended that you keep doing this in all disposable objects. Indeed, using code analyzers in your solutions with warnings as errors will prevent you from accidentally making these mistakes! This will help the GC and will keep your application running with the right amount of memory. Depending on the type of object, mistakes here can snowball, and you could end up with other bad things on a bigger scale, for instance, port/connection exhaustion.
1:297
Another important aspect that you need to know about is that the time spent by the GC collecting objects will interfere with the performance of your app. Because of this, avoid allocating large objects and be careful with event handling and week references; otherwise, it can lead to you always waiting for the GC to finish its task.
1:298
Getting better database access
1:299
One of the most common performance Achilles’ heels is database access. The reason why this is still a big problem is a lack of attention paid while writing queries or lambda expressions to get information from a database. This book will cover Entity Framework Core in Chapter 13, Interacting with Data in C# – Entity Framework Core, but it is important to know what to choose and the correct data information to read from a database. Filtering columns and rows is imperative for an application that wants to deliver on performance.
1:300
The good thing is that best practices related to caching, asynchronous programming, and object allocation fit completely into the environment of databases. It is only a matter of choosing the correct pattern to get better-performing software.
1:301
Case 2 – the user’s needs are not properly implemented
1:302
The more technology is used in a wide variety of areas, the more difficult it is to deliver exactly what the user needs. Maybe this sentence sounds weird to you, but you must understand that developers, in general, study how to develop software, but they rarely study delivering the needs of a specific area. Of course, it is not easy to learn how to develop software, but it is even more difficult to understand a specific need in a specific area. Software development nowadays delivers software to all types of industries. The question here is how can a developer, whether a software architect or not, evolve enough to deliver software in the area they are responsible for?
1:303
Gathering software requirements will help you in this tough task; writing them will make you understand and organize the architecture of the system. There are several ways to minimize the risks of implementing something different from what the user really needs:
1:304
1:305
Prototyping the interface to achieve an understanding of the user interface faster
1:306
Designing the data flow to detect gaps between the system and the user operations
1:307
Frequent meetings to stay up to date on the user’s current needs and be aligned with incremental deliveries
1:308
1:309
Again, as a software architect, you will have to define how the software will be implemented. Most of the time, you are not going to be the one who programs it, but you will always be the one responsible for this. For this reason, some techniques can be useful to avoid the wrong implementation:
1:310
1:311
Requirements are reviewed by the developers to guarantee that they understand what they need to develop.
1:312
Code inspection to validate a predefined code standard. We will cover this in Chapter 4, Best Practices in Coding C# 12.
1:313
Meetings to eliminate impediments.
1:314