mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-08-05 18:24:34 +00:00
docs: Content SEO updates (#2990)
* update yaml frontmatter format * update abstract document * update abstract factory * use the new pattern template * acyclic visitor seo * adapter seo * ambassador seo * acl seo * aaa seo * async method invocation seo * balking seo * bridge seo * builder seo * business delegate and bytecode seo * caching seo * callback seo * chain seo * update headings * circuit breaker seo * client session + collecting parameter seo * collection pipeline seo * combinator SEO * command seo * cqrs seo * commander seo * component seo * composite seo * composite entity seo * composite view seo * context object seo * converter seo * crtp seo * currying seo * dao seo * data bus seo * data locality seo * data mapper seo * dto seo * decorator seo * delegation seo * di seo * dirty flag seo * domain model seo * double buffer seo * double checked locking seo * double dispatch seo * dynamic proxy seo * event aggregator seo * event-based asynchronous seo * eda seo * event queue seo * event sourcing seo * execute around seo * extension objects seo * facade seo * factory seo * factory kit seo * factory method seo * fanout/fanin seo * feature toggle seo * filterer seo * fluent interface seo * flux seo * flyweight seo * front controller seo * function composition seo * game loop seo * gateway seo * guarded suspension seo * half-sync/half-async seo * health check seo * hexagonal seo * identity map seo * intercepting filter seo * interpreter seo * iterator seo * layers seo * lazy loading seo * leader election seo * leader/followers seo * lockable object seo * rename and add seo for marker interface * master-worker seo * mediator seo * memento seo * metadata mapping seo * microservice aggregator seo * api gw seo * microservices log aggregration seo * mvc seo * mvi seo * mvp seo * mvvm seo * monad seo * monitor seo * monostate seo * multiton seo * mute idiom seo * naked objects & notification seo * null object seo * object mother seo * object pool seo * observer seo * optimistic locking seo * page controller seo * page object seo * parameter object seo * partial response seo * pipeline seo * poison pill seo * presentation model seo * private class data seo * producer-consumer seo * promise seo * property seo * prototype seo * proxy seo * queue-based load leveling seo * reactor seo * registry seo * repository seo * RAII seo * retry seo * role object seo * saga seo * separated interface seo * serialized entity seo * serialized lob seo * servant seo * server session seo * service layer seo * service locator seo * service to worker seo * sharding seo * single table inheritance seo * singleton seo * spatial partition seo * special case seo * specification seo * state seo * step builder seo * strangler seo * strategy seo * subclass sandbox seo * table module seo * template method seo * throttling seo * tolerant reader seo * trampoline seo * transaction script seo * twin seo * type object seo * unit of work seo * update method seo * value object seo * version number seo * virtual proxy seo * visitor seo * seo enhancements * seo improvements * SEO enhancements * SEO improvements * SEO additions * SEO improvements * more SEO improvements * rename hexagonal + SEO improvements * SEO improvements * more SEO stuff * SEO improvements * SEO optimizations * SEO enhancements * enchance SEO * improve SEO * SEO improvements * update headers
This commit is contained in:
+18
-16
@@ -1,23 +1,25 @@
|
||||
---
|
||||
title: Tolerant Reader
|
||||
title: "Tolerant Reader Pattern in Java: Enhancing API Resilience and Compatibility"
|
||||
shortTitle: Tolerant Reader
|
||||
description: "Discover how the Tolerant Reader pattern can boost your API's resilience by ignoring unrecognized data, ensuring backward compatibility and seamless integration. Learn through examples and best practices on implementing this robust communication mechanism."
|
||||
category: Resilience
|
||||
language: en
|
||||
tag:
|
||||
- API design
|
||||
- Decoupling
|
||||
- Fault tolerance
|
||||
- Integration
|
||||
- API design
|
||||
- Decoupling
|
||||
- Fault tolerance
|
||||
- Integration
|
||||
---
|
||||
|
||||
## Also known as
|
||||
|
||||
* Lenient Consumer
|
||||
|
||||
## Intent
|
||||
## Intent of Tolerant Reader Design Pattern
|
||||
|
||||
Allows a system to be more resilient to changes in the data structures it consumes by ignoring elements that it does not recognize.
|
||||
The Tolerant Reader pattern enhances system resilience to changes in data structures by strategically ignoring unrecognized elements, promoting robust API design.
|
||||
|
||||
## Explanation
|
||||
## Detailed Explanation of Tolerant Reader Pattern with Real-World Examples
|
||||
|
||||
Real-world example
|
||||
|
||||
@@ -25,13 +27,13 @@ Real-world example
|
||||
|
||||
In plain words
|
||||
|
||||
> Tolerant Reader pattern is used to create robust communication mechanisms between services.
|
||||
> Utilize the Tolerant Reader pattern to establish robust and resilient communication between services, ensuring data compatibility and integration.
|
||||
|
||||
[Robustness Principle](https://java-design-patterns.com/principles/#robustness-principle) says
|
||||
|
||||
> Be conservative in what you do, be liberal in what you accept from others.
|
||||
|
||||
**Programmatic Example**
|
||||
## Programmatic Example of Tolerant Reader Pattern in Java
|
||||
|
||||
We are persisting `RainbowFish` objects to file. Later on they need to be restored. What makes it problematic is that `RainbowFish` data structure is versioned and evolves over time. New version of `RainbowFish` needs to be able to restore old versions as well.
|
||||
|
||||
@@ -169,18 +171,18 @@ Program output:
|
||||
15:38:00.619 [main] INFO com.iluwatar.tolerantreader.App -- deserializedFishV2 name=Scar age=5 length=12 weight=15
|
||||
```
|
||||
|
||||
## Applicability
|
||||
## When to Use the Tolerant Reader Pattern in Java
|
||||
|
||||
* Use when a system needs to consume data from external sources that may change over time.
|
||||
* Apply the Tolerant Reader pattern when your system consumes data from evolving external sources, maintaining efficiency and data integrity.
|
||||
* Applicable when backward compatibility is required in API design.
|
||||
* Suitable for integration scenarios where different systems exchange data and evolve independently.
|
||||
|
||||
## Known Uses
|
||||
## Real-World Applications of Tolerant Reader Pattern in Java
|
||||
|
||||
* JSON or XML parsers that skip unknown elements.
|
||||
* API clients in microservices architectures that interact with multiple versions of a service.
|
||||
|
||||
## Consequences
|
||||
## Benefits and Trade-offs of Tolerant Reader Pattern
|
||||
|
||||
Benefits:
|
||||
|
||||
@@ -193,13 +195,13 @@ Trade-offs:
|
||||
* May result in silent failures if important data is ignored.
|
||||
* Can complicate debugging and tracing of issues due to missing or unrecognized data.
|
||||
|
||||
## Related Patterns
|
||||
## Related Java Design Patterns
|
||||
|
||||
* [Adapter](https://java-design-patterns.com/patterns/adapter/): Both patterns deal with data transformation and integration, but the Adapter Pattern focuses on converting interfaces, while Tolerant Reader focuses on ignoring unrecognized data.
|
||||
* [Facade](https://java-design-patterns.com/patterns/facade/): Simplifies interactions with complex systems, similar to how Tolerant Reader simplifies data consumption by ignoring irrelevant data.
|
||||
* [Strategy](https://java-design-patterns.com/patterns/strategy/): Can be used in conjunction with Tolerant Reader to dynamically switch between different data handling strategies.
|
||||
|
||||
## Credits
|
||||
## References and Credits
|
||||
|
||||
* [Design Patterns: Elements of Reusable Object-Oriented Software](https://amzn.to/3w0pvKI)
|
||||
* [Patterns of Enterprise Application Architecture](https://amzn.to/3WfKBPR)
|
||||
|
||||
Reference in New Issue
Block a user