Lesson 6 | Limitations of design patterns |
Objective | Decide 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
- Architectural patterns consist of: pipes, repository, event, client-server, proxy
- modularity class patterns: iterator, visitor, bridge, strategy, observer
- synchronization: events, locks, monitors, leases
- useful techniques: singleton, object pool
Architectural patterns represent functional relationships between components.
Types of Patterns
Behavioral patterns consist of the following 3 areas.
- algorithms and processing techniques
- resource creation/management techniques
- communication and synchronization techniques
Architecture: pipes and filters
- Application stream data processing and transformation
- Approach: pipeline of generators, transformers, filters
- Advantages
- independence of the processing elements
- power of composing independent elements
- reusability/replaceability of elements
- Limitations: no feedback between stages