braboj / tutorial-python

Awesome Python!
2 stars 2 forks source link

fix(Part B, Ch. 4.2) - Change the code in Adapter-Example #45

Closed Vasc01 closed 1 year ago

Vasc01 commented 1 year ago

In addition to the changes I have made:

I found the two examples from the following link helpful: https://refactoring.guru/design-patterns/adapter/python/example#example-0

braboj commented 1 year ago

Yes, in the example we cover the typical use case where something new has to be adapted to something old. The adapter pattern works also in the opposite direction, but this is a rare scenario. Please revert the changes for applyConfig, because it demonstrates exactly a legacy interface written in Python 2.

⚠️ Please use issue numbers when committing. It is not a problem if there is a more generic issue, like 'Proofread Design Patterns' or something similar.

From PEP-8:

Function and Variable Names Function names should be lowercase, with words separated by underscores as necessary to improve readability. Variable names follow the same convention as function names. mixedCase is allowed only in contexts where that’s already the prevailing style (e.g. threading.py), to retain backwards compatibility.