I don't see a Composite pattern working well with components being objects of heterogeneous types that don't share a common ancestor. You need all the components to inherit some kind of Component
class, possibly with Composite
and Leaf
subclasses to specify a general behavior for leaves and nodes.
How can A know what to inject in C/E? It only knows that it has children of the 'conceptual class'
A shouldn't know it has children of the 'conceptual class'. It should only know it has Component
children. C and E are the ones who know they are of the 'conceptual class'. Depending on your language, this double nature of C and E might be tricky to implement (no multiple inheritance, etc.)
Can you provide details on how the fact that Class E
and Class C
derive from a "conceptual superclass" interferes with the whole composite / execute() / strategy thing ? Without that knowledge, it's hard to recommend anything.