title
stringlengths 3
46
| content
stringlengths 0
1.6k
|
---|---|
3:121 | |
3:122 | The number of days during which the application was beta-tested |
3:123 | The number of bugs found during beta-testing and/or removed by the last code change |
3:124 | Manual approval by one or more managers/team members |
3:125 | |
3:126 | The criteria decision will depend on the way the company wants to manage the product that is being developed. You, as a software architect, must understand that when it comes to moving code to production, the safer, the better. |
3:127 | Usage |
3:128 | As you can see from the preceding screenshots, the process for creating an Azure DevOps account is extremely simple. It is worth mentioning that you can start using this fantastic tool at no cost if you have no more than five developers on your team, plus any number of stakeholders. However, it is worth mentioning that there is no limit on the number of users with a stakeholder role. |
3:129 | Introducing GitHub projects |
3:130 | Considering all the benefits of Azure DevOps presented, you may now be asking why we need to explore another tool. The reason is simple: GitHub has become, over the years, the main tool for the open-source world. So, we will find many initiatives and projects there that have changed the way we deliver software. |
3:131 | The main objective of GitHub is to manage code and guarantee that its users can create solutions in a collaborative way. For this, the platform presents features like version control, pull requests, code reviews, issue tracking, and CI/CD. |
3:132 | However, it would be impossible to design great projects without a platform to support them. That is why we have GitHub projects as an initiative that delivers an adaptable, flexible tool for planning and tracking work on GitHub. |
3:133 | |
3:134 | You can find more information about GitHub projects at https://docs.github.com/en/issues/planning-and-tracking-with-projects/learning-about-projects/about-projects. |
3:135 | |
3:136 | It is quite simple to set up a project on GitHub. Once you log in to the platform, you may find projects from your user menu. |
3:137 | |
3:138 | Figure 3.17: Accessing GitHub projects |
3:139 | There, you will find the option to create a New project. When you decide to create it, you will find different templates already provided by GitHub. |
3:140 | |
3:141 | Figure 3.18: Creating a project on GitHub |
3:142 | The project needs to be linked to a repository. You can do this by accessing the Projects tab in your repo. There, you can also create a new project. |
3:143 | |
3:144 | Figure 3.19: Connecting a GitHub repository to a project |
3:145 | It is worth mentioning that GitHub is more flexible than Azure DevOps, so you will find tools like the ones presented on Azure DevOps, but with different names/definitions. For instance, any task that you will need to define will be called an issue. Each issue can be placed in a milestone, which is a good way to define a feature or user story since it will describe an achievement with a date to be finished. |
3:146 | |
3:147 | Figure 3.20: Setting milestones in a GitHub repository |
3:148 | |
3:149 | Check out more about using issues at https://docs.github.com/en/issues/tracking-your-work-with-issues/about-issues and milestones at https://docs.github.com/en/issues/using-labels-and-milestones-to-track-work/about-milestones. |
3:150 | |
3:151 | The idea of projects on GitHub is to define useful information for each item that will be used, which is documented in an issue. By default, only Title, Assignees, and Status are required. But you can add labels, linked pull requests, reviewers, repositories, and milestones to them. You can also define custom fields, like Iteration. For this, you will need to access Project settings. |
3:152 | |
3:153 | Figure 3.21: Creating custom fields for a GitHub project |
3:154 | In a GitHub project, you can also set different Views, such as Table, Board, or Roadmap. The Table view, in particular, offers a quick and efficient method for entering this project-related information, including the custom fields you’ve created, into the project. Once you’ve completed the design phase, you’re ready to create issues for each item planned in your project. |
3:155 | |
3:156 | Figure 3.22: GitHub project Table view |
3:157 | The Board view, together with a filter related to iteration, is a perfect way to conduct daily meetings because you will see exactly what is happening to the project. |
3:158 | |
3:159 | Figure 3.23: GitHub Board view |
3:160 | To finish, the Roadmap view will give you a perspective of the entire project over time. |
3:161 | |
3:162 | Figure 3.24: GitHub Roadmap view |
3:163 | As you can see, with GitHub projects, you will get almost the same results that we got when using Azure DevOps. |
3:164 | Summary |
3:165 | This chapter covered how you can create an Azure DevOps or GitHub account for a software development project and how to start managing your projects with Azure DevOps or GitHub projects. |
3:166 | It also gave a short review of all of Azure DevOps’ functionalities, explaining how to access them through the Azure DevOps main menu. |
3:167 | To finish, it presented the GitHub project view options to plan and manage a project. |
3:168 | The chapter also described in more detail how to manage system requirements and how to organize the work necessary with various kinds of work items or issues, along with how to plan and organize sprints that will deliver epic solutions with many features. |
3:169 | The decision of whether to use Azure DevOps or GitHub in a project will vary according to the expertise of the team and the objective of the project itself. If you are designing an open-source solution, GitHub will definitely be a better option. On the other hand, if you are designing an enterprise solution and need everything to be connected, Azure DevOps is a fantastic tool to do so. |
3:170 | The next chapter discusses important approaches while writing code. |
3:171 | Questions |
3:172 | |
3:173 | Is Azure DevOps only available for .NET projects? |
3:174 | What kinds of test plans are available in Azure DevOps? |
3:175 | Can DevOps projects use private NuGet packages? |
3:176 | Why do we use work items? |
3:177 | What is the difference between Epic and Feature work items? |
3:178 | What kind of relationship exists between Task and Product Backlog items/User Story work items? |
3:179 | How can GitHub projects be useful? |
3:180 | Which is the better option: Azure DevOps or GitHub? |
3:181 | |
3:182 | Learn more on Discord |
3:183 | To join the Discord community for this book – where you can share feedback, ask questions to the authors, and learn about new releases – follow the QR code below: |
3:184 | https://packt.link/SoftwareArchitectureCSharp12Dotnet8 |
3:185 | |
3:186 | |
3:187 | |
4:1 | Best Practices in Coding C# 12 |
4:2 | When you are the software architect on a project, it is your responsibility to define and/or maintain a coding standard that will direct the team to program according to the expectations of the company. This chapter covers some of the best practices in coding that will help developers like you program safe, simple, and maintainable software. It also includes tips and tricks for coding in C#. Although coding can be considered an art, writing understandable code is closer to a philosophy. In this chapter, we also discuss practices that you, as a software architect, need to propagate to your developers, with techniques and tools for code analysis, so that you have well-written code for your projects. |
4:3 | The following topics will be covered in this chapter: |
4:4 | |
4:5 | How the complexity of your code can affect performance |
4:6 | The importance of using a version control system |
4:7 | Writing safe code in C# |
4:8 | .NET 8 tips and tricks for coding |
4:9 | Identifying well-written code |
4:10 | |
4:11 | C# 12 was launched together with .NET 8. However, the practices presented here can be used in many versions of .NET, since they refer to the basics of programming C#. By the end of the chapter, you will be able to define which tools you are going to incorporate into your software development life cycle to facilitate code analysis. |
4:12 | Technical requirements |
4:13 | This chapter requires, at least, the Visual Studio 2022 free Community Edition. |
4:14 | The simpler your code, the better a programmer you are |
4:15 | For many people, a good programmer is one who writes complex code. However, the evolution of maturity in software development means there is a different way of thinking about it. Complexity does not mean a good job; it means poor code quality. Some incredible scientists and researchers have confirmed this theory and emphasized that professional code needs to be focused on time, high quality, and budget. |
4:16 | Even when you have a complex scenario on your hands, if you reduce ambiguities and clarify the process of what you are coding, especially by using good names for methods and variables, which contribute to making your code “self-documented” and respect SOLID principles (Single Responsibility, Open/Close, Liskov Substitution, Interface Segregation, and Dependency Inversion), you will turn complexity into simple code. |
4:17 | So, if you want to write good code, you need to keep the focus on how to do it, considering you are not the only one who will read it later. This is a good tip that changes the way you write code. This is how we will discuss each point of this chapter. |
4:18 | If your understanding of the importance of writing good code is aligned with the idea of simplicity and clarity while writing it, you should look at the Visual Studio tool known as Code Metrics: |
4:19 | |
4:20 | Figure 4.1: Calculating code metrics in Visual Studio |
4:21 | The Code Metrics tool will deliver metrics that will give you insights regarding the quality of the software you are delivering. The metrics that the tool provides can be found at this link: https://docs.microsoft.com/en-us/visualstudio/code-quality/code-metrics-values. |
4:22 | Once you have run the code metrics analysis, you will need to interpret each metric presented. The following subsections focus on describing how a maintainability index, cyclomatic complexity, depth of inheritance, class coupling, and the number of lines of code are useful in some real-life scenarios. |
4:23 | Maintainability index |
4:24 | The maintainability index represents a number from 0 to 100, which indicates how easy it is to maintain code – the easier the code, the higher the index. Easy maintenance is one of the key points to keeping software in good health. It is obvious that any software will require changes in the future since change is inevitable. |
4:25 | For this reason, consider refactoring your code to elevate the maintainability index if it currently has a low score. Writing classes and methods dedicated to a single responsibility, avoiding duplicate code, and limiting the number of lines of code of each method are examples of how you can improve the maintainability index. |
4:26 | Cyclomatic complexity |
4:27 | The creator of the cyclomatic complexity metric is Thomas J. McCabe. He defines the complexity of a software function according to the number of code paths available (graph nodes). The more paths you have, the more complex your function is. McCabe considers that each function must have a complexity score of less than 10. That means that if the code has more complex methods, you must refactor it, transforming parts of the code into separate methods. There are some real scenarios where this behavior is easily detected: |
4:28 | |
4:29 | Loops inside loops |
4:30 | Lots of consecutive if-else statements |
4:31 | switch with code processing for each case inside the same method |
4:32 | |
4:33 | For instance, look at the first version of this method for processing different responses to a credit card transaction. As you can see, the cyclomatic complexity is bigger than the number considered by McCabe as a basis. The reason why this happens is because of the number of if-else statements inside each case of the main switch: |