Questions tagged [object-composition]

Object composition is about making more complex objects by assembling simpler objects. Do not use this tag for function composition .

Object composition is one of the main mechanism in object oriented programming to combine simpler objects into more complex ones.

For more details, see:

Do not use this tag for:

100 questions
0
votes
1 answer

How to create a Proxy that can compose methods of more than one class?

I have class A that implements interface I. I have two classes B and C, each extends A and adds a new method. The new method in Class B is different from that of C. I need to create a Proxy (sort of composite) that should have all the methods of A…
Kannan
  • 15
  • 7
0
votes
1 answer

Trouble figuring out go object composition

I'm currently using go to implement a Game server due to the awesome concurrency primitives. That has all been a breeze to implement and works very reliably. I come mostly from a Java background though and I am having trouble forgetting Java's type…
Logiraptor
  • 1,496
  • 10
  • 14
0
votes
1 answer

Managing Compound object and mapping properly their attributes using JPA

Again, i arrive at some cross road that make me struggle against the correct principles of object composition designs for a ("rich") domain model objects. Please note that the meaning of composition is the meaning that comes with UML modelling :…
Victor
  • 3,841
  • 2
  • 37
  • 63
0
votes
3 answers

Is it generally considered a bad practice to alter the object's state via its getter method?

I've been thinking about this for a while during my past development. I am kind of against doing such things, I've normally declared a separate method that explicitly handle the logic. E.g. If a Class has a method which return a list of objects, I…
grumpynerd
  • 177
  • 7
0
votes
2 answers

vb.net - Object aggregation of inherited classes

I'm playing around with composition of a couple of objects. I have two classes (Note and task). The Task class is derived from the Note class as a task is an extented note. Each note has a property Property Child as list (of note) as a note or task…
Richard
  • 184
  • 7
-1
votes
1 answer

Will this implementation of comparing two objects in C# work quickly?

I created an implementation of comparing two objects. The IEquatable interface does not suit me because I need a list of specific properties and values that do not match. Will such an implementation work quickly? Or maybe there is some ready-made…
r00xus
  • 79
  • 6
-1
votes
1 answer

C++ composition circular dependency

I'm trying to learn C++ and currently I'm trying to know how to implement an object composition in this language. I have a Character class which is inherited by a Hero and a Monster class. A Character has a NormalAbility and a SpecialAbility. I've…
noxfur
  • 331
  • 1
  • 5
  • 15
-2
votes
1 answer

I wanted to understand how the windows(new rectangle(30, 20)) is working in following code

So i know that new and delete implicitly call constructor but i couldn't get my head around how window(new rectangle (30, 20)) is working. #include using namespace std; class Rectangle { private: double height,…
Muku
  • 538
  • 4
  • 18
-2
votes
5 answers

Creating many objects using composition when the containing class is a singleton pattern

java version 1.7.0_65 I have a singleton design pattern class. That will always return the same instance that is initially created. However, the problem I have is this class needs to create many other objects from another class. I have used…
ant2009
  • 27,094
  • 154
  • 411
  • 609
-2
votes
1 answer

Using constructor when passing an array of objects through composition

#include #include using namespace std; class assistantnurse{ private: char* id; char dutytime; public: assistantnurse(char[] ="", char =' '); void setid(char*); void setdutytime(char); char*…
1 2 3 4 5 6
7