In this article, I’m going to discuss new extension methods and show examples for validating data. In much of the code we write, we validate the state of a variable. In many cases, we use this to change program flow. These methods that I will describe make this very easy along with some added features.
Category: Defensive Programming
Coding Faster with dotNetTips Spargine 6: Validating Arguments Made Easy
For my work moving Spargine to .NET 6, I have completely rewritten the Spargine methods to validate method parameters. In this release, these methods have been changed to allow fluent validation.
dotNetDave Rocks the Philly Code Camp 2022
The dotNetDave For Those About to Code: Worldwide Tour will be at the Philly Code Camp in Philadelphia, PA on March 4th. I hope you will join me at this meeting.
dotNetDave Says… Fixing Bugs Is Like Playing the Game Whack-A-Mole!
Bugs are an unavoidable part of software engineering, akin to a never-ending Whack-A-Mole game. Proper project architecture, adherence to coding standards, and strict enforcement are critical to minimize defects. Leadership plays a crucial role; when standards are neglected, bugs multiply, leading to delays and engineer burnout.
dotNetDave Says… No One Writes Perfect Code!
No one writes perfect code, and that's acceptable. Code reviews provide valuable feedback that can enhance development skills and improve software quality. Embracing constructive criticism fosters collaboration, while avoiding personal interpretations of feedback is crucial. Ultimately, a supportive culture leads to better, safer, and more maintainable software through continuous improvement.
DotNetDave Says… All Data Coming into a Type Must Be Validated!
The post emphasizes the importance of input validation in object-oriented programming (OOP) to maintain encapsulation and code integrity. It highlights common pitfalls due to missing validation, illustrating with examples. By ensuring methods validate inputs at the start, developers can create more robust, maintainable software that prevents invalid data from causing issues.
Serializing Objects Performance: XML Serialization
XML serialization has been around ever since .NET was released since it was so widely used back then. It’s still widely used, especially for legacy applications and services, even iTunes still uses XML to store library information. Benchmark results are for .NET 6 & 7.
Performance: Expanded & Expression Bodied Methods
A newer way of creating simple methods in .NET is by using expression-bodied methods. This article shows which method is more performant.
String Performance: Encoding and Decoding Strings
Encoding and decoding strings to and from a byte[] is used a lot in programming. Performance results are for using the formatting options ASCII, Unicode, UTF8, and UTF32, Latin and BigEndianUnicode. Updated February 2023
String Performance: Combining Strings with the StringBuilder
In programming, efficient string concatenation is crucial. Utilizing the StringBuilder class, especially within loops, offers better performance and reduced memory usage. Methods like AppendFormat() and AppendLine() provide formatting and localization benefits. Benchmark results show StringBuilder's significant speed advantage, with minimal memory allocations. Consistently using StringBuilder for string concatenation is recommended.

You must be logged in to post a comment.