Category Archives for ".NET"

Conditional Attribute in C#

Conditional directives in C# are extremely useful to include or exclude regions of code from compilation. This allows you to target different platforms. Consider a class Logger with a Log method. If you want to log a message only in debug mode you could do something like this. This code is ugly isn’t it? This […]

Continue reading

2 Unsafe and Fixed keywords in C#

C# allows you to manage memory directly when needed mainly for performance reasons. In order to do so you need to compile your code using the /unsafe switch. This is required because this code cannot be verified by the CLR. In Visual Studio you can enable this in the Properties panel. In this post I […]

Continue reading

The Facade Pattern in .NET

The Facade Pattern provides a unified interface to a set of interfaces in a subsystem. Facade defines a higher level interface that makes the subsystem easier to use. The Facade Pattern is the simplest of the patterns and it is something that many developers probably used a lot in the past without even knowing that […]

Continue reading

The Adapter Pattern in .NET

The Adapter Pattern converts the interface of a class into another interface the clients expect. Adapter lets classes work together that couldn’t otherwise because of incompatible interfaces. The pattern is also called “Wrapper” because it is usually implemented using the technique of wrapping objects (object composition). There are different situation when the pattern can be […]

Continue reading

6 The Command Pattern in .NET

The Command Pattern encapsulates a request as an object, thereby letting you parameterize other objects with different requests, queue or log requests, and support undoable operations. The formal definition of the pattern is quite general and it shows how the pattern is versatile and can be used in many scenarios but the real important thing however is the […]

Continue reading

4 Decorator Pattern – Streams in .NET

The Decorator Pattern allows to attach additional responsibilities to an object dynamically. It is an alternative to subclassing for extending behaviour. Instead of creating a silly example of usage I decided to rely on one of the best example of implementation that is already available in the .NET Framework: the Streams. The following class diagram is […]

Continue reading
1 5 6 7
>