Composition is the process of combining, or composing, parts of a program into a larger program.
Questions tagged [composition]
1737 questions
0
votes
1 answer
Scala class method to function with class instance as parameter
I'm pretty sure what I'd like to do is probably not possible and not a good idea anyway. Nonetheless, here it is.
I would like to find a generic way of transforming any method on any class into a function that takes as arguments an instance of the…

user3618414
- 3
- 2
0
votes
4 answers
what's the difference between class type variables or instantiating in a constructor/method
public class MotoXCellPhone {
//assume there's a speaker class
private BlueToothSpeaker speaker;
//why instantiate in constructor?
MotoXCellPhone() {
speaker = new BlueToothSpeaker();
}
//or if i instantiate in a…

Bryan
- 87
- 6
0
votes
1 answer
How to access the same attribute from a class that is composed in two classes in c++?
class AtencionRealizada
{
private:
Paciente *persona;
Atencion aten;
class AtencionRecibida
{
private:
Medico* doctor;
Atencion aten;
The first class has a pointer to the patient and their checkup info while the second class points to the doctor…

user3053042
- 99
- 2
- 16
0
votes
1 answer
Accessing composed objects in Java
New to Java.
I have an instance player1 of the Player class below.
Player player1 = new Player(0,0);
Inside the Player class I have composed an object coordinate of type Coord (defined below). When I instantiate player1 above "Player is at…

Ray Rackiewicz
- 303
- 1
- 3
- 12
0
votes
2 answers
In aggregation, is the "whole's" life dependent on the parts? Can a simple association be a one-to-many relationship?
I have been searching all over the internet and can't seem to find anything that specifically answers my question.
As far as I can tell, a simple association does not imply any form of life dependency.
A Composition is a whole-part relationship…
0
votes
2 answers
How the compiler do composition in inheritance C++?
How the compiler do composition in inheritance?
suppose that I create an object of a derived class where both the base class and the derived class contain via composition object of other classes. I want some example to explain constructors and…

Khan
- 53
- 1
- 7
0
votes
1 answer
What does it mean for 'A Person' has a 'Address object?
In my final ASP.NET assignment, I am instructed to use a code first approach and add the following properties and Model(s) to represent the described changes.
1) A Person 'has a' Address object (This class was given, but I modified adding…

Earl Switzer
- 1
- 1
- 1
- 3
0
votes
1 answer
After Effects clone composition change assets?
I am new to AE and I want to duplicate a composition but the assets belonging to it I want to replace with new footage can I do this?
I have gone into the project window and duplicated the composition however it also references the same images. I…

Dr Schizo
- 4,045
- 7
- 38
- 77
0
votes
3 answers
is it a good practice to assign a class instance to a class attribute in python?
I'm trying to use class composition in python, and I wonder if it is a good practice to assign a class instance to a class attribute in python. Below are the 2 examples which I have in mind. I appreciate if some experienced programmers could tell me…
user188276
0
votes
0 answers
What is the relationship between presented classes?
In the code below I've mentioned relationships between classes. Are they correct?
class D
{
public:
D(C &c) : c_(c) {
}
private:
C &c_; // D compositions C ?? Please make me correct if i am wrong.
};
class C
{
};
void function(C &c)
{
…

sam_k
- 5,983
- 14
- 76
- 110
0
votes
1 answer
Access Parent/Owning class variable from composed class?
Forgive me because I know my wording is terrible. I'll just give an example.
public class MainClass{
public int someVariable;
public List cList = new List();
addHasAClass(HasAClass c){
cList.Add(c);
…

MichelleJS
- 759
- 3
- 16
- 32
0
votes
1 answer
Best pattern for strong typing of class relations
I'm looking for a way to allow relation between instances at compile time.
In an abstract way, that means that several subtypes of an interface are related to multiple properties of the same type, but not all of them compatible in a logical way.…

Whimusical
- 6,401
- 11
- 62
- 105
0
votes
1 answer
Composition, aggregation and DI
Aggregation: the object exists outside the other, is created outside, so it is passed as an argument (for example) to the construtor. Ex: People – car. The car is create in a different context and than becomes a person property.
Composition: the…

Ben Aston
- 53,718
- 65
- 205
- 331
0
votes
1 answer
How to request a c++ feature?
How could I request a C++ feature ?
Who do I have to write to ?
The feature I would like to request is a mere syntax commodity :
When using composition, we need a better syntax in order to provide method forwarding.
Something like what follows …

Julien__
- 1,962
- 1
- 15
- 25
0
votes
1 answer
Multiple Shells (views and view models) and routers for different type of users in Durandal
So I'm trying to build an app that has two different kind of users, namely customers and sellers. The app is designed in such a way that both of them will have different kind of navigation bars and access to different kind of pages via routes. As…

Kendrick Lay
- 15
- 5