Extended Events for SSAS

Cubes require frequent monitoring since their productivity decreases quite often (slowdowns during query building, processing time increment). To find out the reason of decrease, we need to monitor our system. For this, we use SQL Server Profiler. However, Microsoft is planning to exclude this SQL tracing tool in subsequent versions. The main disadvantage of the tool is resource intensity, and it should be run on a production server carefully, since it may cause a critical system productivity loss.

Thus, Extended Events is a general event-handling system for server systems. This system supports the correlation of data from SQL Server which allows getting SQL Server state events. (more…)

Composition and Interfaces in OOP World

In the object-oriented programming world, the concept of inheritance has been criticized for a long time.

There are quite a lot of arguments:

  • A derived class inherits all the parent’s data and behavior that is not always necessary. When modifying a parent class, some data and behavior that are not supposed to be in the derived class get into it;
  • Virtual methods are less productive. If a language allows declaring a non-virtual method, what would you do when you need to override one in an inherited method? You can mark the method with the new keyword, however, in this case, polymorphism will not work. The consequent use of this object may cause unexpected behavior, depending on the type the object is going to be converted to.
  • The vast majority of languages do not allow multiple inheritance.
  • There are tasks where inheritance is helpless. Consider the case, when you need to create a container (array, list, or set) and implement the same behavior for elements with different types. In addition, you need to provide static typing. In this case, generics will come to help.


Sorting in .NET

Sorting is a typical task each programmer should be aware of. That’s why this article is dedicated to the implementation of sorting in .NET. I will describe how array sorting works in .NET, its aspects, and make a small comparison with sorting in Java.

Let’s begin with the fact that the first versions of .NET use the quicksort algorithm by default. So, let’s consider pros and cons of the quicksort.


  1. One of the most high-performance algorithms(on a practical level) of general-purpose internal sorting.
  2. Easy implementation.
  3. Requires just O(logn) of additional memory for its operation.
  4. Can be easily combined with cashing and internal memory mechanisms.


Aspects of Strings in .NET

The string data type is one of the most significant data types in any programming language. You can hardly write a useful program without it. Nevertheless, many developers do not know certain aspects of this type. Therefore, let’s consider these aspects.

Representation of strings in memory

In .Net, strings are located according to the BSTR (Basic string or binary string) rule. This method of string data representation is used in COM (the word ‘basic’ originates from the Visual Basic programming language in which it was initially used). As we know, PWSZ (Pointer to Wide-character String, Zero-terminated) is used in C/C++ for representation of strings. With such location in memory, a null-terminated is located in the end of a string. This terminator allows to determine the end of the string. The string length in PWSZ is limited only by a volume of free space. (more…)

StringBuilder: the Past and the Future

In the previous article, I elaborated on peculiarities of string concatenation. In this article, I would like to consider the StringBuilder class in detail.

As we all know, strings in .Net are immutable (without use of unsafe). Therefore, it is not a good idea to perform concatenation frequently. It means that the following code has quite serious problems with memory load:

So, what is wrong with this code?

The origin of GetHashCode in .NET

This article is devoted to the GetHashCode method and the GetHashCode implementation in the .NET Framework. The article also discusses the different behavior of the method for reference types and value types. The topic is quite interesting and any self-respecting .NET developer needs to know it. So let’s go!

What’s stored in reference-type objects apart from their field?

Let’s begin our story with learning what is stored in reference-type objects in addition to their fields.

Each reference type object has the so-called header, which consists of two fields: a pointer to the type of the object (MethodTablePointer), as well as a synchronization index (SyncBlockIndex).


Foreach or For – That is the Question

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. (more…)

Long Arithmetic from Microsoft

It is known, a computer can operate numbers with a limited number of bits. As a rule, we are accustomed to work with the 32-bit and 64-bit integers. On the .Net platform, the Int32 (int) and Int64 (long) types correspond to these integers.

But what to do if we need to represent, for instance, number 29! = 8841761993739701954543616000000? Such number won’t fit both 32-bit and 64-bit data types. Long arithmetic is designed specifically for working with such big numbers.

In computing technology, long arithmetic implies operations (addition, multiplication, subtraction, division, raising to a power etc.) with numbers, the bitness of which exceeds the length word of the given computer. These operations are implemented not by hardware but by software with the help of basic hardware for working with small-order numbers.


Is string operator “+” so simple?


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.


Under the Hood of Stopwatch


As all developers, I often need to measure the execution time of my own (and not only my own) code. When I was a beginning programmer, I used the DateTime structure for this purpose. Time have passed and I learned about the Stopwatch class and began using it extensively. I think most of you had a similar experience. It’s not like I didn’t wonder about how Stopwatch works, at that time, it was simply enough for me to know that Stopwatch measures the elapsed time more precise than DateTime. Now the time has come to explain to myself as well as to the readers how the Stopwatch class actually works and clarify its pros and cons in comparison with DateTime.