.NET 8 tips and tricks for coding
.NET 8 implements some good features that help us to write better code. One of the most useful things for having cleaner code is dependency injection (DI), which will be discussed in Chapter 6, Design Patterns and .NET 8 Implementation. There are some good reasons for considering this. The first one is that you will only need to worry about disposing of the injected objects if you are 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 8 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.
- Methods should...