Why avoid Conversion Operators

No doubt that the Conversation Operators makes developers life easier by bring in a kind of¬†substitutability, but it comes with a price. If not properly designed/used, it could result in subtle errors that can be easily ignored. Consider the following code. We have a class called Car, which exposes a single property - MakerName. We … Continue reading Why avoid Conversion Operators

Nominal Vs Structural Type System

Anonymous Types and Tuples might look very similar, but there is one significant difference which separates them. As always, nothing can be more explanatory than writing code. Consider the above code. What could be the output ? Are both false or are both true ? Interestingly, the output is as follows. Though syntactically similar, both … Continue reading Nominal Vs Structural Type System

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

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

Regular Expression – Compiled vs Interpreted

Regular Expression gives the developer a clean and efficient method to parse strings. However, it comes at a cost - there is a inherent performance hit associated with regular expressions, especially if you are running some kind of long loops and parsing the string inside it. One way to tackle it is using compiled regular … Continue reading Regular Expression – Compiled vs Interpreted

Design Patterns : Strategy Pattern

Strategy Pattern lets you create a family of strategies (algorithm) encapsulated into separate interchangeable classes. In our example, we will consider a Client class which needs to invoke different sorting algorithm. ¬† Let's first create the contract interface for different Sorting algorithm. Now that we have our interface ready, let's go ahead and implement different … Continue reading Design Patterns : Strategy Pattern

Caliburn Micro #02 : BindableCollection & Events

In the previous part of this series, we looked into some of the basics of using Caliburn Micro. In this part, we will continue with few more examples, how to invoke a method on an event. But before we do that, let's expand our application a bit. Currently the application has two Text controls , … Continue reading Caliburn Micro #02 : BindableCollection & Events