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

Code Smells : Change Preventers

If you ever have been in a situation when you need to make change in one place, but had to make changes in many places too, then Change Preventers is a code smell you should be vary off. Change Preventers is result of poor structuring of code and can be broadly categorized into 3. Divergent … Continue reading Code Smells : Change Preventers

Switching Context With Async

Whenever an await is encountered in the code, a context is captured, which is later used when the promise is completed and ready to continue. If the method is called by the UI thread, usually, the context could be UI context, unless the awaited method itself creates a new thread. This can be demonstrated in … Continue reading Switching Context With Async