Design Patterns

From Exterior Memory
Jump to: navigation, search

Design patterns are common architectures in object-oriented programming. Programmers often come up with the same solution for a problem. These common solutions are called design patterns. This is a short list, with the most patterns.

This is just my own summary of the excellent book Head First Design Patterns published by O'Reilly.

See also UML Basics for the meaning of the arrows in diagrams.

This article is unfinished.

Strategy Pattern

Use has-a property (pointing to another class) instead of is-a (subclass)

Observer Pattern

Observers register themselves at a subject. The subject notifies observes about changes.

Decorator Pattern

Decorate (add behaviour) to a component, by mimicking the base class and wrapping the component in the decorator class.

Powerful: you can add multiple decorators, but has a downside: you end up with lots of small classes.