这是我第一次尝试战略设计模式.
我没有使用Python的架构经验,因此欢迎提出建设性意见.
我将此发布到Stack-Over-Flow,因为我觉得今天早上它可以作为一个健全性检查.显然,据说我没有为这个线程提供足够的上下文(可怕的验证短语),所以我将不得不像鸭子那样使用Quack.
嘎嘎,嘎嘎,嘎嘎:-)
#!/usr/bin/env python
"""
Head First Design Patterns - Strategy Pattern
My attempt to implement the Strategy Pattern, described in Chapter 1.
Sanity Warning: I am currently learning Python, so please don't expect the
exquisite design, planning, construction, and execution of the Curiosity mission.
Expect Ducks... Quacking...
Design Principle: "Favour composition over inheritance"
To the Pythonista community: What is the most elegant, readable, and simplest way
of implementing the HFDP Strategy Pattern?
"""
import abc
"""
Abstract …Run Code Online (Sandbox Code Playgroud)