From the course: Python: Design Patterns (2021)
Unlock the full course today
Join today to access over 24,500 courses taught by industry experts.
Visitor - Python Tutorial
From the course: Python: Design Patterns (2021)
Visitor
- The visitor design pattern allows adding new features to an existing class hierarchy without changing it. It's sometimes necessary to add new operations, dynamically to exist in classes with minimal changes. For our scenario, we present a house class. Visitors in this scenario include an HVAC specialist and an electrician. The HVAC specialist in our scenario is visitor type one, and the electrician is visitor type two. The visitor pattern represents new operations to be performed on the various elements of an existing class hierarchy. Visitors can also provide operations on a composite object.
Contents
-
-
-
-
-
-
(Locked)
Observer1m 5s
-
(Locked)
Observer example6m 22s
-
(Locked)
Visitor56s
-
(Locked)
Visitor example6m 42s
-
(Locked)
Iterator1m 15s
-
(Locked)
Iterator example4m 32s
-
(Locked)
Strategy40s
-
(Locked)
Strategy example5m 44s
-
(Locked)
Chain of responsibility1m 4s
-
(Locked)
Chain of responsibility example5m 57s
-
(Locked)
-
-