Questions tagged [composition]

Composition means to assemble simpler elements into more complex structures. In OOP, composition usually refers to object composition, i.e. assembling several simpler objects into a a more complex aggregate. It may also refer to an aggregation of object, where the aggregate owns some components.

Composition means to assemble simpler elements into more complex structures. In OOP, composition usually refers to object composition, i.e. assembling several simpler objects into a a more complex aggregate. It may also refer to an aggregation of object, where the aggregate owns some components.

See also:

172 questions
13
votes
9 answers

Should a developer know the inner workings of the computers' hardware?

I'm not talking just how memory is assigned and memory management (things that you can learn from C for example) but rather the hardware aspect and how each component of the computer hardware works internally and how they communicate with each…
Adrian
  • 147
6
votes
7 answers

What are the alternatives to "overriding a method" when using composition instead of inheritance?

If we should favor composition over inheritance, the data part of it is clear, at least for me. What I don't have a clear solution to is how overwriting methods, or simply implementing them if they are defined in a pure virtual form, should be…
0
votes
1 answer

Pitfalls of composition where component is also a component of a sibling component?

I'm relatively new to structuring code in a composition style, and I have a situation where a component is also a component of a sibling component. I'm trying to figure out if there are likely to be unexpected issues with this. Explaining the…