Recently, I have often had to use the well-known Visitor pattern. I used to ignore this pattern and thought that it simply complicates the code. In this article, I will share my thoughts about this pattern. We will talk about pros and cons, as well as what tasks it helps to solve and how to simplify its use. The code will be in C#.
When I was programming in C#, I used to send all recursive tasks to an unmanaged C code, since the .NET performance was problematic. And now, looking back at my past experience, I think of the benefits of such code division. Do I really benefit from it, and if yes, how much? What is the best way of building API with such approach? Read More
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.
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.
The discussion about the preference difference between FOREACH and FOR is not new. We all know that FOREACH is slower, but not all know why.
When I started learning .NET, one person told me that FOREACH is two times slower than FOR. He said this without any grounds. I took it for granted.
Eventually, I decided to explore FOREACH and FOR loop performance difference, and write this article to discuss nuances.
Let’s have a look at the following code:
A string data type is one of the fundamental data types, along with numeric (int, long, double) and logical (Boolean) ones. You can hardly imagine at least one useful program that does not utilize this type.
On the .NET platform, the string type is presented as an immutable String class. In addition, it is strongly integrated into the CLR environment and is also supported by the C# compiler.
This article is devoted to concatenation – an operation performed on strings as often as the addition operation on numerals. You may think: “What is there to say?”, after all, we all know about string operator “+”, but as it turned out, it has its own quirks.
You may have been asked a question on a job interview: “What needs to be done to make your class work with the foreach loop?” Well, the answer is “To implement IEnumerable”. The answer is correct but not complete. Read More
The .NET Framework provides a set of powerful string functions. These building blocks can be used to write more complex algorithms for handling string data. To write good string handling functions, it is important to understand the characteristics of string objects in C#. Read More
What is an extension method? The extension method provides the ability to extend the functionality of an existing class by adding a static method into this class, without creating a new derived class, recompiling, or otherwise modifying the original class. The following example demonstrates the extension method in use. Read More