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.
171 questions
0 votes
3 answers
2k views
How to solve a circular dependency with a composition relation?
For a game I'm making I have two objects; Gun and ReloadSystem. At the moment, these two object reference each other. Gun tells ReloadSystem to perform a reload when the gun gets clicked, and ...
2 votes
5 answers
849 views
How does inheritance lead to higher coupling than composition?
One major reason for using composition over inheritance is, that inheritance leads to higher coupling. How is that? In both cases members are exposed to the subclass (in case of inheritance) or ...
2 votes
2 answers
505 views
Composition over inheritance: how data are accessed in the composition case?
I've been reading this Wikipedia article Composition over inheritance. It gives a code example of inheritance first, and then a code example of composition. In case of inheritance there are data that ...
0 votes
2 answers
1k views
Inheritance/Composition VS "Direct Injection Construction"
my following example seems to go into the direction Inheritance VS Composition. But that's not, what i want to ask. I see the concept Inheritance and Composition on one side and the alternative, which ...
0 votes
1 answer
156 views
If we don't use function composition, does Maybe remain a monad?
A monad is a monoid in the category of endofuctors. Category is a set of two things: Set of elements Set of binary operations between these elements. When we talk about the category endofunctors we ...
4 votes
5 answers
2k views
(How) can the circle-ellipse problem be solved by using composition rather than inheritance?
I was reading about composition over inheritance and came across a question about solving the Circle-Ellipse Problem in Object-Oriented Programming. This kind of problem is often used as an example of ...
1 vote
1 answer
742 views
UML Composition parent multiplicity
The Wikipedia article on the Composite Design Pattern includes the following diagram: As you see, there is an association relationship which is child 0..* – 1 parent. However, given that: a ...
5 votes
2 answers
1k views
Design classes to model 3D scanned faces of ancient Greek/Roman sculptures: is multiple inheritance a good design solution?
I would like to deepen the topic of multiple inheritance using Python and I usually find examples that are too simple. I love art and I imagined the following problem and I want to understand if ...