mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-14 10:58:42 +00:00
docs: diagrams for version number, virtual proxy, visitor
This commit is contained in:
+4
-4
@@ -32,6 +32,10 @@ Wikipedia says
|
||||
|
||||
> In object-oriented programming and software engineering, the visitor design pattern is a way of separating an algorithm from an object structure on which it operates. A practical result of this separation is the ability to add new operations to existing object structures without modifying the structures.
|
||||
|
||||
Sequence diagram
|
||||
|
||||

|
||||
|
||||
## Programmatic Example of Visitor Pattern in Java
|
||||
|
||||
Consider a tree structure with army units. Commander has two sergeants under it and each sergeant has three soldiers under them. Given that the hierarchy implements the visitor pattern, we can easily create new objects that interact with the commander, sergeants, soldiers, or all of them.
|
||||
@@ -221,10 +225,6 @@ Program output:
|
||||
14:58:06.118 [main] INFO com.iluwatar.visitor.CommanderVisitor -- Good to see you commander
|
||||
```
|
||||
|
||||
## Detailed Explanation of Visitor Pattern with Real-World Examples
|
||||
|
||||

|
||||
|
||||
## When to Use the Visitor Pattern in Java
|
||||
|
||||
Use the Visitor pattern when
|
||||
|
||||
Reference in New Issue
Block a user