You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The principle to “favour composition over inheritance” is apparently a desirable design pattern
The “decorator pattern” (a class which wraps around a pre-existing class to add functionality) was the memoised dynamic inheritance I disliked when considering how to subclass beeb’s Stream class but also leave it open to others
in fact “multiple inheritance” and “dynamic class building” are both listed as “dodges”!
Solution # 1: The Adapter Pattern
Solution # 2: The Bridge Pattern
Solution # 3: The Decorator Pattern
Solution # 4: Beyond the Gang of Four patterns
Dodge: “if” statements
Dodge: Multiple Inheritance
Dodge: Mixins
Dodge: Building classes dynamically’
I prefer the ‘bridge’ pattern, and suggest switching to that: supplying a handler class from which the other methods would acquire their action from (TODO: review)
The downside is that it isn’t wrapped up neatly, and would require the object to be created in advance. I want to just specify the broadcaster as a string, not have to import the broadcaster-specific class
The text was updated successfully, but these errors were encountered:
(Note: after review, this may end up indicating beeb’s interface is the one to edit)
Following the guide here: https://python-patterns.guide/gang-of-four/composition-over-inheritance/
I prefer the ‘bridge’ pattern, and suggest switching to that: supplying a handler class from which the other methods would acquire their action from (TODO: review)
The text was updated successfully, but these errors were encountered: