Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>A practical answer may be impossible, but I can see where you would have a composition of chains of responsibility. Here's a pythonish example:</p> <pre><code>&gt;&gt;&gt; class DevelopmentPerformanceMonitor(): ... def getPerformanceMonitorHandlers(): ... return [] ... &gt;&gt;&gt; class ProductionPerformanceMonitor(): ... def getPerformanceMonitorHandlers(): ... return [check_cpu_under_load, check_available_hd] ... &gt;&gt;&gt; class DevelopmentExceptionMonitor(): ... def getExceptionHandlers(): ... return [email_local_root, log_exception] ... &gt;&gt;&gt; class ProductionExceptionMonitor(): ... def getExceptionHandlers(): ... return [emails_system_admin, log_exception, create_ticket] ... &gt;&gt;&gt; class SomeSystem: ... pm = None # Performance Monitor ... em = None # Exception Monitor ... def __init__(self, performance_monitor, exception_monitor): ... pm = performance_monitor ... em = exception_monitor ... def on_exception(e): ... for handler in em.getExceptionHandlers(): ... handler(e) ... def perform_performance_monitoring(s): ... for handler in pm.getPerformanceMonitorHandlers(): ... handler(s) </code></pre> <p>So the SomeSystem object is a composite of a performance_monitor and an exception_monitor. Each of the composites will return a series of handlers for desired chain of responsibility. Although this example is really only complicating a simpler Chains of Responsibility, where the SomeSystem could be initiated with the chains themselves. Although keeping them packaged may be helpful.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload