Combining hashcodes of objects

Getting a hashcode of an object in C# is not difficult. All objects has a method (defined by Object type) that can get a hashcode for the user: GetHashCode.

It has its own type of knowledge on how and where to use it, or when creating custom types, how to override this. All should be clarified on the documentation linked above.

In this post however, I want to point out that if you have two objects, how you can combine their hashcodes.

Manually

Find out more


Reading List #2

Let me continue my list of favorite books:

  • Windows Runtime via C#, By: Jeffrey Richter and Maarten van de Bospoort

  • Programming Microsoft Azure Service Fabric, By: Haishi Bai

  • Programming Reactive Extensions and LINQ, By: Jesse Liberty; Paul Betts

  • Pro .NET Performance, By: Sasha Goldshtein; Dima Zurbalev; Ido Flatow

  • Writing High-Performance .NET Code, By: Ben Watson

  • Pro .NET Memory Management, By: Konrad Kokosa

Find out more


Using Blazor and Code Highlight

Code highlight or syntax highlight is a feature that displays text as source code. It is using different fonts and colors, that matches with the syntactical meaning of the code constructs. For examples keywords such as public or if are colored blue, while method names such as Main() can be colored to green. Highlighting code on an HTML website is a relatively easy task if one is using an existing syntax highlighter.

Integrating an existing code highlighter with Blazor is a one step more complex though. In this post, I am going integrate a Blazor site with Prism, which is a lightweight extensible code highlighter.

Getting started

The first step with prism is to choose a theme, additional languages and plugins. Prism will generate a CSS file and a Javascript file, which can be downlaoded from their website. Both files then should be added to the wwwroot folder of the Blazor project.

Find out more


Using NDepend

In this post, I am going get started with a tool called NDepend. NDepend is a static analysis tool, for .net developers, which helps to understand different levels of dependencies in the code. It also provides code metrics, technical debt estimation etc, among many interesting features. I have been looking forward trying it, and in this post, I will have a first glance.

I have a chatbot application to help me with the public transportation waiting times. The core logic of this application has been moved to a class library, but it has been powering a Windows Mobile application, an ASP.Net Core website, a Service Fabric application and an Azure Functions app. Every time, I had hosted in a new platform, I had small change and refactorings on the API, though there should be a good amount of tech debt piled up. Let's see how NDepend can help me find these issues.

Getting Started

NDepend can be installed as a Visual Studio extension or as a standalone app. I have tried both versions. For iterative work, it is handy to have the tool installed as a VS extension, but otherwise, I prefer the standalone executable version of the tool. There is a free trial version and a licensed version as well.

Find out more


Finding Duplicate Integers

This post is a continuation of using Vectorization to achieve better performance. In this post I am going to look at the performance aspect of another tipical programming exercises on interviews.

Task usually goes by this:

Given an array with integers from 1 to N. The order of the integers is unknown. One of the randomly chosen number is duplicated by overwriting another number. Create a method that receives the array as an input and returns the replaced number.For example having an input of [2,5,4,3,1,7,3] should return 3, as being the duplicate, as number 6 is being overwritten by another 3.

I am not going into the details of edge cases, input validation, error handling, etc. This post purely focuses on the performance aspects of some of the possible solutions. I also assume that N = x * 8.

Find out more