LM Tech's blog

Software Architecture & Design Patterns

Microsoft's Unity Application Block (Unity for short) is an Inversion of Control framework wich is part of the Microsoft Enterprise Library 5.0.

Unity is a general-purpose container for use in any type of Microsoft® .NET Framework-based application. It provides all of the features commonly found in dependency injection mechanisms, including methods to register type mappings and object instances, resolve objects, manage object lifetimes, and inject dependent objects into the parameters of constructors and methods and as the value of properties of objects it resolves. More...



Delegate

The delegate is a reference type that can be used to encapsulate a method with a specific signature. Delegates are similar to function pointers in C++; however, delegates are type-safe and secure.

The delegate is declared using the keyword delegate: More...



A callback is a reference to a portion of executable code, that is passed as an argument to other code.
Using callback, for instance, a server program can notify to a caller when the requested operation ends. The callback paradigm can also be used instead of the Observer Design Pattern. In Microsoft .Net Framework, callbacks are implemented using delegates that provides type-safe function pointer.

A delegate is declared using the delegate key-word:

public delegate void OperationCallbackDelegate(int value);
More...



Another way to implement the Inversion of Control (IoC) principle, in addition to the Dependency Injection, is the plug-in design pattern.

The pattern consists in to load an assembly that implements a common interface at runtime. In this way, a class that depends from an object in an other assemby is completely decoupled from it, or rather, it has no reference to dependent assembly. More...



Events are mechanisms that allow application-specific code to execute when an action occurs. In Microsoft .Net Framework events are implemented using delegate (the event handler).

A delegate is a reference type that can be used to encapsulate a method with a specific signature and lets you pass a function as a parameter in type-safe manner. More...



In the observer design pattern an object (the observable) mantain a list of its dependents (the observers) and notifies them when its state changes by calling a method on each registered subscribers. More...



The Separated Interface pattern addresses the problem of separating the interface that describes the functionalities from its implementation. The pattern prescribes that you use different packages (assemblies in the .NET Framework) for the interface and any of its implementations. The packages that need to consume the functionalities know only the definition of the interface and are completely unaware of the implementation. More...



Dependency Injection (DI) is a design pattern that strive to reduce the dependency between components. Dependency Injection is often referred as Inversion of Control (IoC). In fact dependency injection is an application of the Inversion of Control principle.

A class that depends from an other object, receive the reference of the dependent object from the outside world instead of create the instance itself. More...



Jun
09

Singleton

by lma | Tags:

The singleton design pattern force to have only one instance of a class.
The implementation require a mechanism to access the same instance of the class without recreate it every time. It can be achieved creating a class with a method that creates a new instance of the class if one does not exist. If an instance already exists, it simply returns a reference to that object. To make sure that the object cannot be instantiated any other way, the constructor is made protected. More...



The Dependency Inversion Principle (DIP) has been formalized by Robert Martin (http://www.objectmentor.com/resources/articles/dip.pdf). It states:

  • High-level modules should not depend upon low-level modules. Both should depend upon abstractions.
  • Abstractions should not depend upon details. Details should depend upon abstractions

More...