You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: acyclic-visitor/README.md
+3Lines changed: 3 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,7 @@ Allow new functions to be added to existing class hierarchies without affecting
17
17
18
18
## Applicability
19
19
This pattern can be used:
20
+
20
21
* When you need to add a new function to an existing hierarchy without the need to alter or affect that hierarchy.
21
22
* When there are functions that operate upon a hierarchy, but which do not belong in the hierarchy itself. e.g. the ConfigureForDOS / ConfigureForUnix / ConfigureForX issue.
22
23
* When you need to perform very different operations on an object depending upon its type.
@@ -25,11 +26,13 @@ This pattern can be used:
25
26
26
27
## Consequences
27
28
The good:
29
+
28
30
* No dependency cycles between class hierarchies.
29
31
* No need to recompile all the visitors if a new one is added.
30
32
* Does not cause compilation failure in existing visitors if class hierarchy has a new member.
31
33
32
34
The bad:
35
+
33
36
* Violates the principle of least surprise or Liskov's Substitution principle by showing that it can accept all visitors but actually only being interested in particular visitors.
34
37
* Parallel hierarchy of visitors has to be created for all members in visitable class hierarchy.
0 commit comments