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

Limitations of Design Patterns

  1. Design patterns build on the foundations laid by a solid analysis of software development. You will not find a pattern that solves every problem you encounter.
  2. It is valuable to remember that every pattern has its consequences.
  3. Design patterns are not part of a programming languages syntax.

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.


Limitations of Design Patterns in Software Engineering

Question: What are the limitations of design patterns within the realm of software engineering?
  1. Not Universal Solutions: Design patterns address recurring problems in software design. However, they aren't universally applicable. Implementing a design pattern without a genuine need can introduce unnecessary complexity and overhead.
  2. Technology and Paradigm Shifts: While patterns abstract from specific technologies, they don't always adapt seamlessly to new technological advancements or programming paradigms. Over-reliance on established patterns may hinder the adoption of innovative techniques or solutions.
  3. Learning Overhead: There exists a broad range of design patterns, each with its specific intent and nuances. Understanding them fully requires a significant investment of time and effort, which can be a deterrent for developers new to the domain.
  4. Performance Trade-offs: Certain patterns, particularly those introducing additional layers of abstraction, can impact system performance. The Proxy or Decorator patterns, for instance, while providing flexibility, may introduce latency in system operations.
  5. Inflexible in Changing Contexts: Once a particular design pattern is deeply embedded into a system, evolving or changing the system's design can become challenging without a comprehensive refactoring, which can be costly and time-consuming.
  6. Misuse and Overuse: Due to their popularity and perceived benefits, there's a tendency to overuse or misuse patterns. This can lead to over-engineered solutions where simpler designs might suffice.
  7. Variability in Implementation: The conceptual nature of design patterns means they aren't tied to specific implementations. While this provides flexibility, it can also lead to variations in how patterns are implemented, potentially causing inconsistencies in software projects.
  8. Potential for Stifling Innovation: An overemphasis on established patterns can curb the inclination to think outside the box. Relying solely on known patterns might limit the exploration of novel solutions to unique problems.

While design patterns offer invaluable insights and solutions to common software design challenges, they are not without limitations. Prudent software engineering requires recognizing these constraints and employing design patterns judiciously, ensuring that the chosen patterns align with the specific needs and context of the project at hand.

A Pattern's 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

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.

  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

Observer Class - Exercise

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