【发布时间】:2018-12-19 17:12:40
【问题描述】:
我有一个用 Python 编写的 OOP 解决方案,主要专注于管理不同类型的硬件组件,例如摄像头、伺服、接近传感器等。
我拥有的是一群运营经理。操作管理器基本上是一个类,其中定义了多个公共方法。我定义的规则如下:
1. Different operation managers can call each other’s public methods
2. Multiple operation managers are involved into one specific use-case
3. Operation manager's method execution depends on the result of the previous operation manager (if previous was successfully executed - execute this one, otherwise terminate)
4. Each operation manager must be able to report its failure to a common channel (logging)
5. There’s no need for a transactional behavior (rollback)
我在这里的目标是能够
- 轻松集成新的运营经理
- 能够测试特定用例(一组操作管理器操作)
- 引入一定程度的抽象,让不同的运营经理相互解耦。
我一直在关注CoR,但仍然不确定它是否是我的最佳选择。
【问题讨论】:
标签: python design-patterns raspberry-pi chain-of-responsibility