add functionality to a Java class without polluting its hierarchy with a common superclass

M-am lovit de problema asta, unele workflow-uri sa trimita mesaje de GDPR,

– Favor composition over Inheritance

– Inheritance
Toate clasele Workflow care vor sa aiba behaviour-ul asta in puls, sa extinda DefaultWorkflow si sa faca chestia aia in pulus

– Composition
– Behavior-ul asta in plus sa fie adus de un adaptor Class,

– Sau inca o abordare,
“if you want to add some sort of functionality to Java classes without polluting their hierarchy with a common superclass, consider creating a separate interface just for this one utility method.”
https://zeroturnaround.com/rebellabs/java-8-best-practices-cheat-sheet/

see the Debuggable example