Please let me know if this is inappropriate as formulated (in particular whether Programmers.SE or something would be better for the question.)
Alright. So I’ve got a number of ‘traits’ that I’m currently expressing as interfaces. Let’s call them “updatable” and “destructible”. Expressing them as interfaces has the downside that I can’t share behavior between all “destructible” components; on the other hand, expressing these as abstract classes mean I can’t mix and match without explicitly defining the mixed trait as another abstract class (“UpdateableAndDestructible”) and furthermore this feels like an abuse of the abstract class functionality at that point. It’s probably what I’ll end up doing if there aren’t cleaner ways of handling this, however.
What are my options as far as pure Java solutions to this conundrum? Is it possible for me to describe shared behavior and then mix and match as I see fit without having to explicitly describe every permutation I’ll be using?
Maybe you could achieve the goal by using a mix of interfaces and default implementations.
Like:
Still noisy and maybe not as flexible as you would like but maybe a bit cleaner than doing the UpdatableAndDestructable thing.