Skip to main content

Posts

Showing posts from November, 2008

Let's talk about design patterns

Do you know the difference between Adapter and Decorator patterns?

These two patterns are made to wrap objects. Humm... Same goals? Not exactly. On the first hand, the Adapter pattern is used to transform your class interface contract to another one. In the real world, you use it to "adapt" your code to an external piece of code you need.

In the other hand, with the decorator pattern, your class keeps its interface contract. You just wrap your code to bring some new features. For example, you decorate a class to integrate a counter on method calls and perform a performance test.