LM Tech's blog

Software Architecture & Design Patterns

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



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