Designing Software  «Prev  Next»
Lesson 6Limitations of design patterns
ObjectiveDecide whether to alter the Observer pattern.

Limitations of Design Patterns

Design patterns build on the foundations laid by solid analysis of software development. You will not find a pattern that solves every problem you encounter. Some problems are simply intractable and unmanageable. Other problems may have a solution, but there are no widely known patterns to solve the challenge at hand. Indeed, this may be an opportunity for you to make a mental note by documenting a pattern you invent, discover or document as you synthesize existing patterns to create new patterns.

A pattern's consequences

It is valuable to remember that every pattern has its consequences. For instance, most pattern approaches, especially ones that rely on polymorphism, are slightly slower than an equivalent solution that does not encourage reuse. However, this may be trivial compared to the time saved using the pattern. Each design decision must be considered individually. Only use a design pattern if its benefits outweigh its costs.

Avoid getting locked into specific interpretations of patterns

Design patterns are not part of a programming language's syntax. They are ways to think about and organize solutions to common problems.
They are not written in stone. If a pattern is not working for you, you can change the pattern to make it work.

Observer Class - Exercise

In this exercise, you will decide whether to modify the Observer pattern or not.
Observer Class - Exercise

  1. Architectural patterns consist of: pipes, repository, event, client-server, proxy
  2. modularity class patterns: iterator, visitor, bridge, strategy, observer
  3. synchronization: events, locks, monitors, leases
  4. useful techniques: singleton, object pool
Architectural patterns represent functional relationships between components.

Types of Patterns

Behavioral patterns consist of the following 3 areas.
  1. algorithms and processing techniques
  2. resource creation/management techniques
  3. communication and synchronization techniques

Architecture: pipes and filters

  1. Application stream data processing and transformation
  2. Approach: pipeline of generators, transformers, filters
  3. Advantages
    1. independence of the processing elements
    2. power of composing independent elements
    3. reusability/replaceability of elements
  4. Limitations: no feedback between stages