Single Responsibility Principle (SRP) helps us write more cohesive types and methods. Cohesion is the relatedness of the members of a type to each other and the relatedness parts of a method's code to other parts. Method cohesion Often times a method is not very cohesive, meaning the code that it...
Let's look at the ubiquitous Person concept. It might seem logical that an application that deals with people should have a Person interface for classes to implement. For example: public interface IPerson { String GivenName { get; set; } String SurName { get; set; } IAddress Address { get; set; ...
With increased usage of patterns and situationally specific strategies, people sometimes lose sight of the concepts and principles behind these patterns and strategies and fail to follow them when they're not using patterns or strategies. I feel it's good to periodically review the fundamental...
I ran into an interesting problem on the Forums recently. Basically, when you use MethodInfo.Invoke to invoke a method with by-reference value type arguments you can't have the invoked method update a variable/argument. The problem is, when you invoke the method the parameter is passed to the MethodInfo...
I was debugging what I thought was a strange exception the other day. The exception was an InvalidOperationException and the message was "Object is currently in use elsewhere". Unless you're familiar with this exception, it really doesn't offer much as to why the exception is occurring...
In recent blog post I detailed how creating a culture via the CultureInfo constructor could actually create a user-overridden culture--which could be completely different than the culture that you've requested by name. Fortunately there's a way of overriding the user override (apologies for overloading...
Sometimes you may want to use a specific format for formatting and parsing of textual data. The easiest way to do this is to select a specific culture and use that with formatting and parsing methods. Unfortunately, the CultureInfo constructor that just takes the name of the culture defaults to accepting...