Design Patterns : State Pattern

State Pattern is share a lot of similarities with Strategy Pattern, but has its own fundamental differences as well. The State pattern allows to change the behavior of a method, depending on the state of an object, in other words it encapsulates the behavior dependent on the state (the What). This is different from the … Continue reading Design Patterns : State Pattern

Design Patterns : Null Object Pattern

Null Pattern is probably one of the most underestimated and often most ignored among the design Patterns., though it turns out to be one of the easiest to implement. The intend of the pattern is to ensure we won't end up with NullReference Exceptions, while avoiding the long list of repeated preconditions that checks of … Continue reading Design Patterns : Null Object Pattern

Evil Code #005 : Readonly Value Types

Time to review another of Evil Code Series and this time, we are dealing with read-only value types. Review the below code and predict the output.     Strangely enough, the output is {3,2}. Yes, it means the Increment Method return a value of 3 for MyValue, but a follow-up statement to display MyValue explicitly, … Continue reading Evil Code #005 : Readonly Value Types

Benchmarking Span<T> Performance

Span<T> is yet another addition to C# 7.x and is particularly useful in developing memory intensive applications.  So what is Span all about ?   As Microsoft describes it, Span<T> is a new value Type which enables the representation of contiguous regions of arbitrary memory, regardless of whether the memory is associated with a managed … Continue reading Benchmarking Span<T> Performance

Technical Debt Quadrant

In a practical corporate software development scenario, there are times when you have (willingly or otherwise) to give up to trade-offs and compromises  especially when the deadlines looms over you or, in worst case, you are LAZY !!. You might be prompted to choose a less than optimal solution due to situational constraints, which might … Continue reading Technical Debt Quadrant

Reference Semantics and Code Readability

One of the features Microsoft packed with C# 7.2 is Reference Semantics with Value Types. Though designed with the intention to improve performance by eliminating the need for copying (and thereby allocating memory) value types , I do have my reservations on the complexity it adds to readability of code for a programmer. Let's consider … Continue reading Reference Semantics and Code Readability