.NET

Free .NET Enterprise Books

.NET Enterprise Solutions … Software Engineers on their way to Pluto
 

.NET Enterprise Solutions … Best Practices for the Connoisseur
 

.NET Enterprise Solutions … Interoperability for the Connoisseur
Downloadable here

Design Pattern in .NET 101 - Abstract Factory Pattern (Creational Pattern)

Download Sample Code
Abstract Factory pattern provides an interface for creating families of related or dependent objects without specifying their concrete classes.
E.g. I have a DocumentFactory class that either returns DefaultDocumentFactory or CustomDocumentFactory dependening on the environment variable.

using System;
using System.Collections.Generic;
using System.Text;

namespace AbstractFactory
{
abstract class DocumentFactory
{
[…]

Design Pattern in .NET 101 - Factory Method Pattern (Creational Pattern)

Download Sample Code
Factory Method Pattern defines an interface for creating an object, but let subclasses decide which class to instantiate. It lets a class defer instantiation to subclasses.
E.g., I defined a abstract News class.

using System;
using System.Collections.Generic;
using System.Text;

namespace FactoryPattern
{
abstract class News
{
}
}

Different kinds of […]

Design Pattern in .NET 101 - Facade Pattern (Structural Pattern)

Download Sample Code
Facade Pattern provides a unified interface to a set of interfaces in a subsystem. It defines a higher-level interface that makes the subsystem easier to use.
E.g.
I have a Call Details Record (CDR) to be processed by different systems. It is defined in the CDR class

using System;
using System.Collections.Generic;
using System.Text;

namespace FacadePattern
{
class […]

Design Pattern in .NET 101 - Decorator Pattern (Structural Pattern)

Download Sample Code
Decorator Pattern attaches additional responsibilities to an object dynamically and provides a flexible alternative to subclassing for extending functionality.
E.g.
BaseMessage is defined

using System;
using System.Collections.Generic;
using System.Text;

namespace DecoratorPattern
{
abstract class BaseMessage
{
private string sender;
[…]

Design Pattern in .NET 101 - Proxy Pattern (Structural Pattern)

Download Sample Code
Proxy Pattern provides a surrogate or placeholder for another object to control access to it.
E.g.
I defined a IGreeting interface

using System;
using System.Collections.Generic;
using System.Text;

namespace ProxyPattern
{
interface IGreeting
{
void SayHello();
}
}

Greeting implements IGreeting

using System;
using System.Collections.Generic;
using System.Text;

namespace ProxyPattern
{

[…]