Posts related to .NET programming.
Extending CLAP For Larger Applications
If you’ve been reading my recent posts you’ve probably noticed that I’ve been working a lot with the CLAP project lately. For anyone who is not familiar with that project, its name is an acronym that stands for Command Line Auto Parser. It lets you quickly and easily take an array of command-line arguments passed into a .NET application and map them to one or more target classes that expose methods. CLAP takes the strings representing the arguments and automatically parses them and passes them into ......
Posted On Wednesday, August 28, 2013 9:37 PM | Comments (0)
A Simple Approach For Presenting With Code Samples
I’ve been getting ready for a presentation and have been struggling a bit with the best way to show and execute code samples. I don’t present often (hardly ever), but when I do I like the presentation to have a lot of succinct and executable code snippets to help illustrate the points that I’m making. Depending on what the presentation is about, I might just want to build an entire sample application that I would run during the presentation. In other cases, however, building a full-blown application ......
Posted On Wednesday, July 31, 2013 10:04 PM | Comments (0)
Extending sp_WhoIsActive With context_info
If you work with SQL Server you should be familiar with Adam Machanic’s fantastic sp_WhoIsActive stored procedure. This procedure provides high levels of detail about all commands that are currently being executed on a SQL Server instance. I’ve found it immensely helpful for troubleshooting long-running queries and locking/contention issues in live production SQL Server instances. That said, I’ve always wanted to include one extra little bit of information in the dataset that sp_WhoIsActive returns: ......
Posted On Sunday, April 28, 2013 2:16 PM | Comments (0)
Beware Singletons that Raise Events
It’s pretty well documented that one of the most common ways in which a .NET application can “leak” memory stems failing to unsubscribe from events when the subscription is no longer needed. This answer to a Stack Overflow question on memory leaks in C# describes the issue very succinctly: Event Handlers are a very common source of non-obvious memory leaks. If you subscribe to an event on object1 from object2, then do object2.Dispose() and pretend it doesn't exist (and drop out all references from ......
Posted On Sunday, January 27, 2013 9:32 PM | Comments (2)
YAGNI and Professional Code
I’ve heard (and used) YAGNI (You Ain’t Gonna Need It) quite often in my software development career. It’s a battle cry for shipping a minimum viable product and letting the real-world usage dictate what new features and improvements are really needed. Generally speaking I think that this ruthless minimalism is a good thing. I think we’ve all fallen into the “pie in the sky” thinking about adding lots of bells and whistles to whatever feature we’re working on. I for one also know the feeling of spending ......
Posted On Monday, December 31, 2012 12:28 PM | Comments (0)
On StringComparison Values
When you use the .NET Framework’s String.Equals and String.Compare methods do you use an overloStringComparison enumeration value? If not, you should be because the value provided for that StringComparison argument can have a big impact on the results of your string comparison. The StringComparison enumeration defines values that fall into three different major categories: Culture-sensitive comparison using a specific culture, defaulted to the Thread.CurrentThread.Curren... value (StringComparison.CurrentCu... ......
Posted On Sunday, October 21, 2012 12:44 PM | Comments (0)
Enumerations And The CStr Function
Anyone who has worked with Visual Basic for any length of time should be familiar with the VB Type Conversion Functions like CBool, CInt, and CStr. These functions can provide a short and easy way to coerce the value of one type into another. I’ve been working with ~300,000 line VB .NET project for the past couple of years that is littered with calls to these functions. We never had any issues with them until we sat down to convert the project to C#. Converting a 300,000 line project from VB .NET ......
Posted On Tuesday, January 24, 2012 9:11 PM | Comments (0)
Tag Cloud