The fifth edition of David McCarter's book, "Röck Yöur Cöde: Code & App Performance for Microsoft .NET," is now available on Amazon. It offers practical techniques for enhancing .NET application performance, including coding patterns, memory insights, and benchmarking. This definitive guide is essential for modern .NET developers aiming for speed and scalability.
Category: Code Analysis
Code It Anyway You Want: Initializing Reference Type Static Fields Inline for Enhanced Code Readability
Microsoft advises initializing reference type static fields inline to enhance code readability and prevent issues from uninitialized fields. Two patterns are shown: inline initialization and using a static constructor. While both methods do not allocate memory, using a static constructor may slightly improve performance. EditorConfig can check for adherence to this guideline.
Rock Your Code: Coding Standards for Microsoft .NET (20th Anniversary Edition)
The 20th Anniversary Edition of Rock Your Code: Coding Standards for Microsoft .NET, authored by David McCarter, is now available on Amazon. This comprehensive guide offers updated standards for .NET 10, best practices, and expert insights, making it essential for software engineers aiming for improved code quality and performance over two decades.
Coding Faster with dotNetTips Spargine: Validating Data Made Easy with Validator
In their experience as a software engineer, the author emphasizes the importance of data validation to prevent errors caused by bad input. They introduce Spargine's Validator class, which offers various methods to validate data effectively. Incorporating these methods can lead to cleaner and more reliable code, enhancing application stability.
Coding Faster with dotNetTips Spargine: Validating Arguments Made Easy with Validator
The article emphasizes the importance of input validation in software engineering, highlighting its role in avoiding errors and maintaining data integrity. It discusses Spargine's Validator class, detailing various validation methods that support seamless integration and best practices for exception handling. The piece advocates for wider implementation of these techniques in .NET development.
Microsoft .NET Code Analysis: Best Practices and Performance for Comparing Strings
String comparisons in .NET are essential for various operations like authentication and sorting, but they must be used correctly to avoid performance issues or bugs. The article outlines the proper use of Equals() for equality checks and Compare() for ordering. It emphasizes measuring performance before assuming Span-based methods are faster, highlighting the importance of intent in choosing string comparison APIs.
Microsoft .NET Code Analysis: Improve .NET Performance by Reusing Constant Arrays
In optimizing the Spargine project, I improved performance by avoiding constant arrays as method arguments. Instead, using static readonly fields reduced memory allocations significantly. This change enhanced execution speed, yielding a 1.34x performance gain. I recommend enabling CA1856 warnings in .editorconfig to maintain performance-focused coding practices.
Microsoft .NET Code Analysis: Boosting Performance with [ConstantExpected] Attribute for Methods
The [ConstantExpected] attribute in .NET enhances code performance by signaling that methods should receive compile-time constants as arguments. While not enforcing this at runtime, it improves coding practices and efficiency. In the Spargine project, it clarified intent and identified issues early, particularly with .NET 10's performance improvements across parameter types.
Microsoft .NET Code Analysis: Optimizing Collection Examination
This content discusses four methods for evaluating items in a collection using predicates or filters, mainly focusing on the LINQ Any() method. It highlights the performance of Count() as superior to Any(), LongCount(), and Exists() under specific conditions, especially in asynchronous operations where CountAsync() is the fastest.
Microsoft .NET Code Analysis: Boosting Performance with Span and Memory
The excerpt discusses the .NET MemoryExtensions class, which optimizes performance in byte array manipulation by offering allocation-free methods for converting to Memory, ReadOnlyMemory, Span, and ReadOnlySpan.

You must be logged in to post a comment.