Skip to content

Commit d17e8b1

Browse files
committed
updates
1 parent 3699fba commit d17e8b1

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

visitor/README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Visitor Design Pattern
22

3+
## Videos
4+
5+
Section | Video Links
6+
-|-
7+
Visitor Overview | <a id="udemyVideoLink" href="https://www.udemy.com/course/design-patterns-in-python/learn/lecture/25697738/?referralCode=7493DBBBF97FF2B0D24D" target="_blank" title="Visitor Overview"><img src="/img/udemy_btn_sm.gif" alt="Visitor Overview"/></a>&nbsp;<a id="ytVideoLink" href="https://youtu.be/KLFLsDV-LXw" target="_blank" title="Visitor Overview"><img src="/img/yt_btn_sm.gif" alt="Visitor Overview"/></a>&nbsp;<a id="skillShareVideoLink" href="https://skl.sh/34SM2Xg" target="_blank" title="Visitor Overview"><img src="/img/skillshare_btn_sm.gif" alt="Visitor Overview"/></a>
8+
Visitor Use Case | <a id="udemyVideoLink" href="https://www.udemy.com/course/design-patterns-in-python/learn/lecture/25697742/?referralCode=7493DBBBF97FF2B0D24D" target="_blank" title="Visitor Use Case"><img src="/img/udemy_btn_sm.gif" alt="Visitor Use Case"/></a>&nbsp;<a id="ytVideoLink" href="https://youtu.be/9JJO2ZaZD3A" target="_blank" title="Visitor Use Case"><img src="/img/yt_btn_sm.gif" alt="Visitor Use Case"/></a>&nbsp;<a id="skillShareVideoLink" href="https://skl.sh/34SM2Xg" target="_blank" title="Visitor Use Case"><img src="/img/skillshare_btn_sm.gif" alt="Visitor Use Case"/></a>
9+
hasattr() Method | <a id="udemyVideoLink" href="https://www.udemy.com/course/design-patterns-in-python/learn/lecture/25697748/?referralCode=7493DBBBF97FF2B0D24D" target="_blank" title="hasattr() Method"><img src="/img/udemy_btn_sm.gif" alt="hasattr() Method"/></a>&nbsp;<a id="ytVideoLink" href="https://youtu.be/cWNARNXP6dE" target="_blank" title="hasattr() Method"><img src="/img/yt_btn_sm.gif" alt="hasattr() Method"/></a>&nbsp;<a id="skillShareVideoLink" href="https://skl.sh/34SM2Xg" target="_blank" title="hasattr() Method"><img src="/img/skillshare_btn_sm.gif" alt="hasattr() Method"/></a>
10+
expandtabs() Method | <a id="udemyVideoLink" href="https://www.udemy.com/course/design-patterns-in-python/learn/lecture/25697758/?referralCode=7493DBBBF97FF2B0D24D" target="_blank" title="expandtabs() Method"><img src="/img/udemy_btn_sm.gif" alt="expandtabs() Method"/></a>&nbsp;<a id="ytVideoLink" href="https://youtu.be/FT6XGI2vJqQ" target="_blank" title="expandtabs() Method"><img src="/img/yt_btn_sm.gif" alt="expandtabs() Method"/></a>&nbsp;<a id="skillShareVideoLink" href="https://skl.sh/34SM2Xg" target="_blank" title="expandtabs() Method"><img src="/img/skillshare_btn_sm.gif" alt="expandtabs() Method"/></a>
11+
312
## Book
413

514
Cover | Links
@@ -155,9 +164,3 @@ ghi 789
155164
jklmn 1011
156165
```
157166

158-
## Summary
159-
160-
* Use the Visitor pattern to define an operation to be performed on the elements of a hierarchal object structure.
161-
* Use the Visitor pattern to define the new operation without needing to change the classes of the elements on which it operates.
162-
* When designing your application, you can provision for the future possibility of needing to run custom operations on an element hierarchy, by implementing the Visitor interface in anticipation.
163-
* Usage of the Visitor pattern helps to ensure that your classes conform to the single responsibility principle due to them implementing the custom visitor behavior in a separate class.

visitor/client.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ class Body(AbstractCarPart, IVisitable):
5959
"A part of the car"
6060

6161
def __init__(self, name, sku, price):
62-
self._name = name
63-
self._sku = sku
64-
self._price = price
62+
self.name = name
63+
self.sku = sku
64+
self.price = price
6565

6666
def accept(self, visitor):
6767
visitor.visit(self)
@@ -71,9 +71,9 @@ class Engine(AbstractCarPart, IVisitable):
7171
"A part of the car"
7272

7373
def __init__(self, name, sku, price):
74-
self._name = name
75-
self._sku = sku
76-
self._price = price
74+
self.name = name
75+
self.sku = sku
76+
self.price = price
7777

7878
def accept(self, visitor):
7979
visitor.visit(self)
@@ -83,9 +83,9 @@ class Wheel(AbstractCarPart, IVisitable):
8383
"A part of the car"
8484

8585
def __init__(self, name, sku, price):
86-
self._name = name
87-
self._sku = sku
88-
self._price = price
86+
self.name = name
87+
self.sku = sku
88+
self.price = price
8989

9090
def accept(self, visitor):
9191
visitor.visit(self)
@@ -95,7 +95,7 @@ class Car(AbstractCarPart, IVisitable):
9595
"A Car with parts"
9696

9797
def __init__(self, name):
98-
self._name = name
98+
self.name = name
9999
self._parts = [
100100
Body("Utility", "ABC-123-21", 1001),
101101
Engine("V8 engine", "DEF-456-21", 2555),

0 commit comments

Comments
 (0)