Functional C#

C# is a multi-paradigm programming language. Recently, the course has been set towards new functional constructions in C#. We can go further and add other extension methods that allow writing less code without ‘climbing’ in the F# territory.

(more…)

Specification Design Pattern in C#

In computer programming, the specification pattern is a particular software design pattern, whereby business rules can be recombined by chaining the business rules together using boolean logic. The pattern is frequently used in the context of domain-driven design.

In short, the main benefit of using “specifications” is a possibility to have all the rules for filtering domain model objects in one place, instead of a thousand of lambda expressions spread across an application.

(more…)

Why Using Unit Tests is a Great Investment into High-Quality Architecture

I have decided to write this article in order to show that unit tests are not only a tool to grapple with regression in the code but is also a great investment into a high-quality architecture. In addition, a topic in the English .NET community motivated me to do this. The author of the article was Johnnie. He described his first and last day in the company involved in the software development for business in the financial sector. Johnnie was applying for the position – of a developer of unit tests. He was upset with the poor code quality, which he had to test. He compared the code with a junkyard stuffed with objects that clone each other in any unsuitable places. In addition, he could not find abstract data types in a repository: the code contained only binding of implementations that cross request each other.

(more…)

Comparing Objects by Value. Part 6: Structure Equality Implementation

We have already analyzed peculiarities of structs of the .NET framework that represent Value Types when comparing objects by value – instance of structs.

Now, I am going to describe this process on a particular example to check whether it will allow us to determine the use of the object comparison by value in general and thus, to simplify a sample of comparing objects by value – class instances that represent reference types.

(more…)

Comparing Objects by Value. Part 4: Inheritance & Comparison Operators

In the previous article, we analyzed how to compare objects by value on a particular example with the Person class that includes:

(more…)

Comparing Objects by Value. Part 3: Type-specific Equals and Equality Operators

In Part 1 and Part 2, we have analyzed how to modify a class to compare objects by value.

Now, we will explore a type-specific implementation of how to compare objects by value including the IEquatable(Of T) generic interface and overload of “==” and “!=” operators.

Type-specific comparison of objects by value allows achieving:

  • a more stable, scalable and mnemonic (readable) code through overloaded operators;
  • higher performance.

(more…)