LM Tech's blog

Software Architecture & Design Patterns

The factory design pattern is a creational pattern that favor the abstraction of the objects creation's process.
The creation of an object can be a complex process where many properties must be setted and other nested objects must be created.
To reduce the code duplication and the coupling between classes, is better to put the creation code in a unique place (the factory), where you can access to get the instance of the objects.
A "factory" therefore, is an object for creating other objects. 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...



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...



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...



The Liskov's Substitution Principle (LSP) was introduced by Barbara Jane Liskov in 1987.
It states that if class X is derived from a class Y, Y may be replaced with X without altering any of the desirable properties of the program.

Briefly: Subclasses should be substitutable for their base classes.

Ref.: http://en.wikipedia.org/wiki/Liskov_substitution_principle