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:
Ilkka Seppälä
2024-06-08 19:54:44 +03:00
committed by GitHub
parent cb946c0cdc
commit 6cd2d0353a
219 changed files with 3308 additions and 2819 deletions
+24 -22
View File
@@ -1,12 +1,14 @@
---
title: Dirty Flag
title: "Dirty Flag Pattern in Java: Optimizing Performance with Change Tracking"
shortTitle: Dirty Flag
description: "Learn about the Dirty Flag design pattern in Java for efficient state tracking and resource management. Avoid unnecessary computations with practical examples and use cases."
category: Behavioral
language: en
tag:
- Game programming
- Performance
- Resource management
- State tracking
- Game programming
- Performance
- Resource management
- State tracking
---
## Also known as
@@ -14,11 +16,11 @@ tag:
* Change Tracking
* Is-Modified Flag
## Intent
## Intent of Dirty Flag Design Pattern
The Dirty Flag design pattern is employed to avoid unnecessary computations or resource-heavy operations by maintaining a boolean flag that tracks whether the state of an object has changed ('dirty') or remains unchanged ('clean'). This flag, when set, indicates that a particular operation, such as recalculating or refreshing data, needs to be performed again to reflect the updated state.
## Explanation
## Detailed Explanation of Dirty Flag Pattern with Real-World Examples
Real-world example
@@ -32,7 +34,7 @@ Wikipedia says
> A dirty bit or modified bit is a bit that is associated with a block of computer memory and indicates whether the corresponding block of memory has been modified. The dirty bit is set when the processor writes to (modifies) this memory. The bit indicates that its associated block of memory has been modified and has not been saved to storage yet. When a block of memory is to be replaced, its corresponding dirty bit is checked to see if the block needs to be written back to secondary memory before being replaced or if it can simply be removed. Dirty bits are used by the CPU cache and in the page replacement algorithms of an operating system.
**Programmatic Example**
## Programmatic Example of Dirty Flag Pattern in Java
The `DataFetcher` class is responsible for fetching data from a file. It has a dirty flag that indicates whether the data in the file has changed since the last fetch.
@@ -106,43 +108,43 @@ The program output is as follows:
12:06:02.616 [pool-1-thread-1] INFO com.iluwatar.dirtyflag.App -- UNITED_STATES
```
## Applicability
## When to Use the Dirty Flag Pattern in Java
* When an operation is resource-intensive and only necessary after certain changes have occurred.
* In scenarios where checking for changes is significantly cheaper than performing the operation itself.
* Within systems where objects maintain state that is expensive to update and the updates are infrequent.
* In scenarios where checking for changes is significantly cheaper than performing the operation itself, enhancing cost-effectiveness.
* Within systems where objects maintain state that is expensive to update and the updates are infrequent, promoting performance efficiency.
## Tutorials
## Dirty Flag Pattern Java Tutorials
* [89: Design Patterns: Dirty Flag (TakeUpCode)](https://www.takeupcode.com/podcast/89-design-patterns-dirty-flag/)
## Known Uses
## Real-World Applications of Dirty Flag Pattern in Java
* Graphic rendering engines to update only parts of the scene that have changed.
* Graphic rendering engines to update only parts of the scene that have changed, utilizing the Dirty Flag pattern for efficient rendering.
* Web applications for partial page rendering or caching strategies.
* Database applications for tracking changes in datasets to minimize write operations.
* Database applications for tracking changes in datasets to minimize write operations, ensuring efficient database management.
## Consequences
## Benefits and Trade-offs of Dirty Flag Pattern
Benefits:
* Reduces computational and resource overhead by avoiding unnecessary operations.
* Can significantly improve performance in systems where operations are costly and changes are infrequent.
* Simplifies the decision-making process about when to perform certain operations.
* Reduces computational and resource overhead by avoiding unnecessary operations, leading to performance gains.
* Can significantly improve performance in systems where operations are costly and changes are infrequent, fostering system optimization.
* Simplifies the decision-making process about when to perform certain operations, aiding in effective resource allocation.
Trade-offs:
* Introduces complexity by adding state management responsibility to the system.
* Requires diligent management of the flag to ensure it accurately reflects the state changes, avoiding stale or incorrect data.
* Potentially increases the risk of bugs related to improper flag resetting.
* Potentially increases the risk of bugs related to improper flag resetting, impacting system reliability.
## Related Patterns
## Related Java Design Patterns
* [Observer](https://java-design-patterns.com/patterns/observer/): Can be used in conjunction to notify interested parties when the dirty flag is set or cleared.
* [Memento](https://java-design-patterns.com/patterns/memento/): Useful for storing the previous state of an object, which can work hand in hand with dirty flag logic to revert to clean states.
* [Command](https://java-design-patterns.com/patterns/command/): Commands can set the dirty flag when executed, indicating a change in state that requires attention.
## Credits
## References and Credits
* [Game Programming Patterns](https://amzn.to/3PUzbgu)
* [J2EE Design Patterns](https://amzn.to/4dpzgmx)