lundi 17 décembre 2018

Is chain of responsibility design pattern suitable for Python solution operating over hardware components

I have an OOP solution written in Python which is mostly focused on managing different kind of hardware components such as camera, servo, proximity sensors etc.

What I have is a bunch of operation managers. An operation manager is basically a class which has more than one public methods defined inside of it. The rules I have defined are as follows:

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)

What I am aiming here is to be able to

  • easily integrate a new operation manager
  • Be able to test a specific use-case (set of operation manager operations)
  • Bring a level of abstraction and have the different operation managers decoupled from each other.

I have been looking at CoR but still not sure if it is the best option for me or not.

Aucun commentaire:

Enregistrer un commentaire