mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-14 08:58:26 +00:00
docs: poison pill and private class data diagrams
This commit is contained in:
@@ -29,6 +29,10 @@ In plain words
|
||||
|
||||
> Poison Pill is a known message structure that ends the message exchange.
|
||||
|
||||
Sequence diagram
|
||||
|
||||

|
||||
|
||||
## Programmatic Example of Poison Pill Pattern in Java
|
||||
|
||||
In this Java example, the Poison Pill serves as a shutdown signal within message queues, demonstrating effective thread management and consumer communication.
|
||||
@@ -210,10 +214,6 @@ Program output:
|
||||
07:43:01.520 [Thread-0] INFO com.iluwatar.poison.pill.Consumer -- Consumer CONSUMER_1 receive request to terminate.
|
||||
```
|
||||
|
||||
## Detailed Explanation of Poison Pill Pattern with Real-World Examples
|
||||
|
||||

|
||||
|
||||
## When to Use the Poison Pill Pattern in Java
|
||||
|
||||
Use the Poison Pill idiom when:
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 58 KiB |
@@ -33,7 +33,6 @@ Architecture diagram
|
||||
|
||||

|
||||
|
||||
|
||||
## Programmatic Example of Presentation Model Pattern in Java
|
||||
|
||||
The Presentation Model design pattern is a pattern that separates the responsibility of managing the state and behavior of the GUI in a separate model class. This model class is not tied to the view and can be used to test the GUI behavior independently of the GUI itself.
|
||||
|
||||
@@ -33,6 +33,14 @@ Wikipedia says
|
||||
|
||||
> Private class data is a design pattern in computer programming used to encapsulate class attributes and their manipulation.
|
||||
|
||||
Mind map
|
||||
|
||||

|
||||
|
||||
Flowchart
|
||||
|
||||

|
||||
|
||||
## Programmatic Example of Private Class Data Pattern in Java
|
||||
|
||||
Imagine you are cooking a stew for your family dinner. You want to stop your family members from tasting the stew while you're still preparing it. If they do, there might not be enough stew left for dinner.
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 85 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 222 KiB |
Reference in New Issue
Block a user