.NET 6 tips and tricks for coding
.NET 6 implements some good features that help us to write better code. One of the most useful things for having safer code is dependency injection (DI), which was discussed in Chapter 10, Design Patterns and .NET 6 Implementation. There are some good reasons for considering this. The first one is that you will not need to worry about disposing of the injected objects since you are not going to be the creator of them.
Besides, DI enables you to inject ILogger, a useful tool for debugging exceptions that will need to be managed by try-catch
statements in your code. Furthermore, programming in C# with .NET 6 must follow the common good practices of any programming language. The following list shows some of these:
- Classes, methods, and variables should have understandable names: The name should explain everything that the reader needs to know. There should be no need for an explanatory comment unless these declarations are public. ...