Agile Principles, Patterns, and Practices in C#

Agile Principles, Patterns, and Practices in C# by Robert C. Martin and Micah Martin describes how to write software using C#. Book covers also most important design patterns and object-oriented development principles. There are very good, close to reality examples for every topic and that makes this book pretty easy to read and understand.

Read more

Using memory mapped files with C#

.Net Framework 4.0 introduces memory mapped files. Memory mapped files are useful when you need to do in-memory data manipulation and your data structures are large. For large in-memory data the performance of memory mapped file is the best. It is much faster thanMemoryStream. And like files on hard disc, memory mapped files can be shared between different programs. MemoryMappedFile and other classes for memory mapped files can be found from System.IO.MemoryMappedFiles namespace.

Read more

Performance of Fibonacci numbers algorithms

Performance of algorithms is important topic if you want to write programs that work fast and doesn’t eat too much resources. In this example I will show you two implementations of famous Fibonacci numbers algorithm and let you compare how these two implementations perform. This posting will be also introduction to my next posting to keep it smaller and to keep focus on point.

Read more

How parallel LINQ works

.Net Framework 4.0 has parallel computing extensions for LINQ. Previously it was possible to download parallel extensions for LINQ separately from CodePlex. Of course, you can still use these extensions if you have older version that 4.0. I wrote a little, simple and pretty pointless example that illustrates how parallel queries work in .Net Framework 4.0.

Read more

Resizing images without loss of quality

ASP.NET provides us with System.Drawing namespace where we can find classes we can use to manipulate with images. There are many people out there who mistakenly think thatImage.GetThumbnailImage is best choice for image resizing. You can easily create crappy images if you follow the code examples in previously pointed article. In this post I will show you how to resize images without negative side effects.

Read more

Hiding loggers implementations using Unity

Loggers are one of most popular examples about interfaces for sure. And there are a lot of implementations of loggers. Some implementations are simple and yet powerful, some implementations may be more complex. All we have to is to select implementation we need and integrate it to our application. It seems like good idea at first place but as soon as we need to switch from one implementation to another we discover nasty dependencies we have to change in all places where we are logging. Let’s see how to avoid these dependencies.

Read more

Refactoring: adapt parameter

Sometimes you are not able to use Extract Interface refactoring because interface of parameter may be too large or there may be no interface at all. You just have class to pass in and you are not able to fake it or extend it to get class testable. In this case you have to use Adapt Parameter refactoring to create adapter that is seen through common some common class of interface.

Read more

Refactoring: reduce variable scope

In good code variables are used as short as possible. Often we can see code where variables are defined in wider scope than it is necessary. There are many examples about too wide scopes. One of fuzziest of them is variable that is defined in class scope but it used only by one method and this method uses this variable as local variable. But variable life time can also be reduced in local scope. To achieve this we use refactoring method called reduce variable scope.

Read more

Refactoring: extract interface

Extract interface is one of the most common refactoring techniques. Motivation behindextract interface refactoring method is to avoid direct dependencies between classes. Instead of using classes in method calls we use interfaces so we can also use subclasses of those classes we used before. Also we can create brand new classes that use follow these interfaces and we can use these classes instead of current ones.

Read more

Some notes about custom C# application and Exchange Server 2003 integration

Custom C# application and Exchange Server 2003 integration over WebDAV was one of the tasks I lately worked on. I made posting about how to log on to Outlook Web Access when FBA is used but I didn’t mentioned that I had to read data from Exchange public folders. There are some stuff that may drive you nuts but there are also some tricks to use to get everything work as expected.

Read more

Refactoring: introduce constant

One way to write messy code is to use constant values in code without any explanations about their values or purpose. Sometimes it feels like too small problem to think about, specially when there are only couple of constants, but I am sure that hard coded constants may waste developers valuable time more than one may think at first place. To make this kind of code easier to read and understand we can use refactoring method called introduce constant.

Read more