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

Multicasting with Action

Func and Action are inherited from System.MulticastDelegate, which means that you could actually do multicasting with them and add multiple methods to the InvocationList. Let's check how we do it. Output of above code would be The same can be done with Func as well. How do we remove one Action , same syntax as … Continue reading Multicasting with Action

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

Code Smells : Object Oriented Abusers

While a well implemented Objected Oriented code is a hallmark of a good program, a poor implementation of the same couldĀ  lead to utter chaos as the project progresses. Object Oriented Abusers are a particular genre of Code Smells which refers to incorrect or incomplete implementation of Object Oriented Concepts. Switch Statements Switch Statements are … Continue reading Code Smells : Object Oriented Abusers

Code Smells : Bloaters (Primitive Obsession, Long Parameter List, Data Clumps)

Primitive Obsession If there is a code smell I often misses, then it has to be Primitive Obsession. Quite honestly, I have been guilty of falling for Primitive Obsession more than once. This particular type of Code Smell refers to the tendency of Developers to use primitive types instead of small objects for stimulating certain … Continue reading Code Smells : Bloaters (Primitive Obsession, Long Parameter List, Data Clumps)

Caliburn.Micro #006 : Event Aggregators & Window Managers

Consider the classic scenario when you need to show the currently logged in User Name in your main Window, once you have successfully logged in. The The login Window is supposed to be a Modal Dialog, and isn't remotely aware of the Label displaying Username in the Main Window. WPF handles Modal Dialogs and messaging … Continue reading Caliburn.Micro #006 : Event Aggregators & Window Managers

Code Smells : Bloaters (Long Methods, Long Class)

Code Bloats or Code Bloaters are probably the most common signs of code smells you can see in any branch of code. In fact, eradicating bloaters act as the first step towards refactoring your code. Bloaters are nothing but classes or methods that have grown excessively over a long time marking it difficult to work … Continue reading Code Smells : Bloaters (Long Methods, Long Class)