note:wed_jun_25_2025

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
note:wed_jun_25_2025 [2025/06/25 09:56] root1note:wed_jun_25_2025 [2025/06/25 14:36] (current) lingao
Line 4: Line 4:
  
  
 +====== Visitor Pattern ======
  
 +To perform an operation on a pastry, we call its accept()  method and pass in the visitor for the operation we want to execute. The pastry—the specific subclass’s overriding implementation of accept()—turns around and calls the appropriate visit method on the visitor and passes itself to it.
 +
 +That’s the heart of the trick right there. It lets us use polymorphic dispatch on the pastry classes to select the appropriate method on the visitor class. In the table, each pastry class is a row, but if you look at all of the methods for a single visitor, they form a column.
  
  • note/wed_jun_25_2025.1750845385.txt.gz
  • Last modified: 2025/06/25 09:56
  • by root1