mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-10-14 16:17:25 +00:00
docs: add diagrams for marker interface, master-worker, mediator, memento, metadata mapping, microservices api gateway, microservices log aggregation, monad, monitor, monostate, multiton, mute idiom
This commit is contained in:
1 parent
72eeb167c5
commit
8d5cb59388
24 files changed
+48
-4
No files matched your search
@@ -34,6 +34,10 @@ wiki.c2.com says
|
||||
|
||||
> A monostate is a "conceptual singleton" - all data members of a monostate are static, so all instances of the monostate use the same (static) data. Applications using a monostate can create any number of instances that they desire, as each instance uses the same data.
|
||||
|
||||
Flowchart
|
||||
|
||||

|
||||
|
||||
## Programmatic Example of Monostate Pattern in Java
|
||||
|
||||
The Monostate pattern in Java ensures that all instances of a class share the same state, making it a great Singleton alternative for maintaining consistent data. This is achieved by using static fields in the class. Any changes to these fields will be reflected across all instances of the class. This pattern is useful when you want to avoid global variables but still need a shared state across multiple instances.
|
||||
|
||||
Reference in new issue
Block a user