Questions tagged [composition]

Composition is the process of combining, or composing, parts of a program into a larger program.

1737 questions
0
votes
1 answer

C++ Composition, How can an Object know about the Class it is In?

For example, I have two classes, Game and Logic. Game has-a unique pointer to an object named m_Logic. class Game { public: Game(){} private: std::unique_ptr m_Logic; }` class Logic { public: Logic() bool Run(Game &pGame) {…
0
votes
0 answers

LSP : Inheritance vs Composition

I need to respect the LSP while supporting multiple data types (templates can't be used) and I have a dilemma between inheritance and composition. If I use inheritance, the base class cannot be used by itself, it must be casted everytime. Does that…
0
votes
1 answer

A list of objects with data from multiple bounded contexts

First of all, I'm quite new in DDD, so I may get some concepts wrong. The problem I'm facing in is as follows: I have a list of tickets for some processing system. The tickets are based on a data from external sources crawled / tracked by Crawlin…
Tomasz Struczyński
  • 3,273
  • 23
  • 28
0
votes
2 answers

Pattern for sharing data between views (MVP or MVVM)

What is a good pattern for sharing data between related views?. I have an application where 1 form contains many small views, each views behaves independently from each other more or less (they communicate/interact via an event bus). Every so often…
Dovix
  • 65
  • 6
0
votes
2 answers

Set within a Map in Java

I was wondering if it is possible to have a Set member added as a member variable of a class, the object of which can then be put as a value into a Map. My idea is to use HashSet projects as a member variable for my employee class. But, I would…
ha9u63a7
  • 6,233
  • 16
  • 73
  • 108
0
votes
3 answers

how could one class calls another class's method in which one is not a parent or child class of another?

I am reading observer pattern design and could not understand the logic behind how one class calls the method of another class's method which one is not parent/child of another. for instance i have the following Company and Employee classes. public…
Tesfa Zelalem
  • 619
  • 1
  • 9
  • 18
0
votes
1 answer

Extend javafx.scene.paint.Color by getRGB method

I am converting my SWING application to JavaFX application. The swing application makes use of the java.awt.Color.getRGB() method. javafx.scene.paint.Color does not have the getRGB() method. Therefore I wanted to extend the …
Guido
  • 926
  • 2
  • 10
  • 19
0
votes
1 answer

UML definition - Generalization, aggregation and abstract classes

I'm a bit confused regarding Generalization, Aggregation and abstract classes in UML. By Generalization, I can understand that it's a "is a"-relationship. A student is a Person - and a teacher is a Person. So Person would be the superclass, whereas…
Adem Ökmen
  • 326
  • 3
  • 4
  • 15
0
votes
1 answer

Establishing a parent-child-relationship in object oriented design

Suppose we want to model students which attend courses. Every student should attend at most one course at a time and a course can contain multiple students (a typical 1-to-n association). Suppose further that this association should be…
proskor
  • 1,382
  • 9
  • 21
0
votes
3 answers

What is a good way to implement composition in Java?

The following classes display the concept of Composition in Java: //Imagine constructors, accessors & mutators has already been created.. class Person{ private String name; private Job job; //Person has Job } class Job{ private…
user3437460
  • 17,253
  • 15
  • 58
  • 106
0
votes
1 answer

What is preferred composition or aggregation in UML?

I am synthesizing all the UML patterns - Like Adaptor Pattern, Commander Pattern, Wrapper Pattern. My question is what is preferred composition or aggregation. Also, why is it preferred so ?
user3629119
  • 151
  • 1
  • 9
0
votes
2 answers

Multiple compositions in UML

In a UML class diagram, is it technically correct to have two possible compistion relationships leading to one class? I.E. I have an inventory class, which has a composition of the inventory class. I want to have the same relationship but with a…
LightMikeE
  • 719
  • 3
  • 8
  • 17
0
votes
3 answers

Aggregation and Composition Implementation in java using Class Diagram

I am trying to understand the aggregation and Composition. Suppose I have something like below: and I want to implement it using java, is the below implementation correct ? public class ClassC { private String z; } public class ClassB { …
iAmLearning
  • 1,153
  • 3
  • 15
  • 28
0
votes
2 answers

Array indexing lens out of array and index lenses

This is a simpler version of Using lens for array indexing if both array and index are in State as I have resolved some issues. I'm not sure if I should delete the original or edit it in place. Given {-# Language TemplateHaskell #-} {-# Language…
nponeccop
  • 13,527
  • 1
  • 44
  • 106
0
votes
1 answer

Class composition - Call outer method from inner class

I have a outer class that has another class as a member ( following the principle composition over inheritance ). Now I need to call a method of the outer class from the class within. class Outer { var $inner; __construct(Inner $inner) { …
Lorenz Meyer
  • 19,166
  • 22
  • 75
  • 121
1 2 3
99
100