Best of .NET — 2024
- 1
- 2
Ardalis·2y
From Microservices to Modular Monoliths
Struggling with the complexity of microservices? Consider migrating to a modular monolith. This approach maintains the gains from breaking up a legacy system without dealing with the issues of a massively distributed system. A modular monolith can simplify management, reduce latency, and keep communication efficient among well-defined modules. However, such a migration needs careful planning and execution.
- 3
Waseem .NET Newsletter·2y
Top 18 Essential .NET Libraries for Developers
A guide to 18 essential .NET libraries for developers, detailing their use cases, benefits, and trivia. Libraries include Mediator for CQRS, Dapper for micro-ORM, Serilog for logging, and more. Each library is briefly explained with implementation links provided.
- 4
InfoWorld·2y
Best practices for handling exceptions in C#
Effective exception handling is crucial for building robust applications. Key practices include deriving custom exceptions from the Exception class, handling exceptions at the highest level in the call hierarchy, using specific exceptions for clarity, employing try/catch/finally blocks for resource cleanup, and avoiding the re-throwing of exceptions to maintain stack trace integrity. Always log exceptions properly and use validation logic to minimize the need for exceptions.
- 5
Community Picks·2y
Faster Dictionary in C#
The .NET Base Class Library's Dictionary<TKey, TValue> offers constant time access to values, but duplicated lookups can reduce efficiency. Utilizing the TryAdd method in .NET Core 2.0 can prevent duplicate lookups and boost performance. Additionally, .NET 6 introduced methods in System.Runtime.InteropServices.CollectionsMarshal to address duplicate lookup scenarios using managed pointers. These methods, alongside managed pointers and the ref keyword, can significantly speed up dictionary operations, particularly with structs and large structures. However, it's crucial to handle managed pointers cautiously to avoid potential issues with dictionary reorganization.
- 6
Milan Jovanović·2y
Building Your First Use Case With Clean Architecture
Learn how to design a user registration feature using Clean Architecture principles, focusing on the dependency rule to decouple business logic from external dependencies. Clean Architecture emphasizes separation of concerns, making systems more maintainable and testable. The practical guide covers defining use cases, managing dependencies, handling race conditions, and updating hashing algorithms.
- 7
- 8
DEV·2y
Understanding IQueryable<T> in C#
Understanding IQueryable<T> in C# is crucial for efficient data querying. This interface, integral to LINQ, supports deferred execution and expression trees, enabling optimized and flexible queries over data sources like SQL databases or in-memory collections. It allows for method chaining to build complex queries and can be extended using custom extension methods for functionality like filtering, sorting, and pagination.
- 9
Hacker News·2y
The .NET Programmer's Playground
LINQPad offers interactive querying for databases in LINQ and SQL. It generates association properties automatically, making data access simple. LINQPad supports various databases, caches intermediate results, and features a Dump method for intelligent object inspection. It supports advanced C# features, acts as a rapid coding tool, and offers functionalities such as benchmarking and Excel export. LINQPad also includes a tutorial and numerous example queries, making it easy to learn.
- 10
freeCodeCamp·2y
How To Use LINQ in C# – With Code Examples
LINQ, part of the .NET framework, allows for powerful data querying through both language-level query syntax and method syntax. This post covers various LINQ methods such as `OrderBy`, `First`, `Single`, `SingleOrDefault`, and `Select` with examples on how to apply them. It also delves into deferred execution and method chaining, demonstrating how LINQ can optimize performance and allow for more complex, readable queries. Writing defensive code to handle changes in data over time is emphasized for error prevention.
- 11
- 12
DEV·2y
Part 2 :Design Principles in Software Development
Adhering to fundamental design principles in software development—such as Dependency Inversion, Separation of Concerns, Single Responsibility, DRY (Don't Repeat Yourself), and Persistence Ignorance—is key to creating robust, maintainable, and scalable applications. Each principle contributes to keeping the codebase clean and efficient, which in turn simplifies maintenance and extension of the software.
- 13
Waseem .NET Newsletter·2y
EP 66 : Clean Code Tips for .NET Developers - Part I
This post provides clean code tips for .NET developers, focusing on giving meaningful names, avoiding null returns, keeping class and method sizes small, not reinventing the wheel, and using appropriate tools or IDEs. It also offers practical examples and suggestions for better coding practices in .NET projects.
- 14
ASP.NET Blog·2y
Performance Improvements in .NET 9
Exciting performance improvements are packed into .NET 9, making it the best and fastest release so far. More than 7,500 pull requests, with a significant focus on performance, contribute to this release. Key highlights include dynamic profile-guided optimization (PGO), enhanced just-in-time (JIT) compiler optimizations, refined tier 0 compilation, loop optimizations, and reductions in bounds checking overheads. These changes collectively enhance runtime efficiency, memory management, and overall application speed.
- 15
Waseem .NET Newsletter·2y
EP 62 : Dependency Injection Explained in .NET
Dependency injection is a programming technique in which an object receives other required objects instead of creating them internally. Benefits of dependency injection include automatic handling of object creation and disposal, easy unit testing, and adaptability to changes without affecting existing code. Dependency injection can be implemented using the singleton, transient, or scoped approach.
- 16
Telerik·2y
Tips for Improving API Performance in ASP.NET Core
Learn how to optimize APIs in ASP.NET Core to improve performance and scalability with techniques including caching, asynchronous communication, pagination, and efficient code practices. These methods can reduce latency, enhance user experience, and optimize server resource usage. Examples provided include moving to async methods, implementing pagination, using AsNoTracking in Entity Framework, and employing both in-memory and distributed caching.
- 17
- 18
Milan Jovanović·2y
Clean Architecture: The Missing Chapter
Clean Architecture is about dependencies, not folders. Many developers mistakenly turn the Clean Architecture diagram into a project structure, but the focus should be on managing dependencies. Traditional layer-based organization scatters related components and creates maintenance challenges. Organizing code by feature or component helps achieve better dependency management and business focus. The post provides practical examples and best practices for implementing these principles in .NET, highlighting the importance of managing dependencies and keeping related code together.
- 19
Milan Jovanović·2y
Improving Code Quality in C# With Static Code Analysis
Static code analysis is a vital tool for improving code quality in C# projects. It helps detect issues related to security, performance, and coding style without running the code. The post covers how to set up static code analysis using built-in Roslyn analyzers in .NET, configure properties in `Directory.Build.props`, and leverage additional tools like `SonarAnalyzer.CSharp`. The process involves treating warnings as errors and customizing rules via `.editorconfig` to create secure, maintainable, and high-quality code.
- 20
ASP.NET Blog·2y
C# 13: Explore the latest preview features
C# 13 introduces new features focusing on flexibility, performance, and enhancing everyday use. Key updates include enhancements to params collections, new lock object improvements for mutual exclusion, index operator improvements, a new escape sequence for the ESC character, and the introduction of partial properties. Additionally, there are enhancements to method group natural type determination and relaxed restrictions for ref and unsafe contexts in async methods and iterators. The preview can be tried with the latest .NET 9 and Visual Studio 2022 updates.
- 21
habr·2y
Spans in C#: Your Best Friend for Efficient Coding
Spans in C# provide a powerful way to handle memory efficiently, reducing allocations and improving performance. They allow for direct manipulation of memory regions, support safe code practices, and are stack-allocated. This guide covers their use, differences between Span<T> and ReadOnlySpan<T>, and practical examples, including JSON parsing, converting arrays, and strings to spans. Ensuring proper scope and compatibility with development environments is crucial for optimal use.
- 22
- 23
freeCodeCamp·2y
How to Benchmark Your Code in C#
Learn how to benchmark and optimize your C# code using BenchmarkDotNet, a powerful library for accurate performance measurements. Discover why Stopwatch is not reliable for detailed benchmarking, understand key metrics like mean, error, and standard deviation, and explore how to measure memory allocation and garbage collection impacts. This guide also explains running benchmarks across different .NET frameworks and inputs for comprehensive performance insights.
- 24
Code Maze·2y
Advanced Debugging in C#
This post delves into advanced debugging techniques in C# using Visual Studio 2022. It covers conditional breakpoints, tracepoints, hit count, and filter conditions. The post also explains how to change breakpoint locations, edit code during a debugging session, use the execution pointer, set function and dependent breakpoints, track variables with object IDs, and utilize string visualizers for viewing formatted strings.
- 25
Waseem .NET Newsletter·2y
EP 52 : Best Practices for .NET Projects
This post discusses best practices for .NET projects, including optimal folder structure, utilizing shared class libraries, organizing constants, installing necessary class libraries, cleaning up Program.cs, setting up a global exception handler, and leveraging tools and strategies for .NET development enhancement.