Questions tagged [composite]

The Composite pattern is a design pattern that allows a group of objects to be treated in the same way as a single instance of an object. It is one of the Gang of Four's structural design patterns.

Overview

The Composite pattern is a design pattern that allows a group of objects to be treated in the same way as a single instance of an object.

It is one of the Gang of Four's structural , first published in Gamma et al.'s book "Design Patterns: Elements of Reusable Object-Oriented Software".

The Composite pattern may sometimes coincide with the use of composite data types and composite variables.

See also

979 questions
0
votes
1 answer

function to expand out composite field to lucene queries

I am having trouble implementing a function that would apply composite fields to Lucene queries. Instead of typing the lucene query: title:"The Right Way" subject:"The Right Way" I want users to be able to type: all:"The Right Way" Where all is…
0
votes
2 answers

composite pattern computer game

For a computer game the rewards for the player as he/she progresses through the game are: Entry level: Lamp worth n points Intermediate level: magic mat m points Advanced level: treasure chest which can be filled with lamps or mats Here we apply the…
Annita Zirki
  • 147
  • 1
  • 1
  • 8
0
votes
1 answer

Understanding composite in java or GWT

I have problem in understanding a composite. In Frame class i have verticalPanel(vp) when vp is loaded , getAction and get Button is visible on vp WHen click on button there is a getTree is executed and there is treeC class initialized where there…
NewCodeLearner
  • 738
  • 3
  • 14
  • 38
0
votes
1 answer

How to adding scroll bar and it work in Composite

ScrolledComposite sc = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL); Composite composite = new Composite(sc, SWT.NONE); composite.setSize(1000, 1000); composite.setLayout(new FillLayout()); …
-1
votes
1 answer

USB composite Device instance IDs

I am developing a USB composite device. The composite device have 8 switches and one LED. When I plugged the Composite device to PC,I could find five devices (each with same device ID but different instance IDs) in the HID section of Device…
Vivek
  • 59
  • 4
-1
votes
1 answer

How print the entire data structure created with Composite?

I have class-Composite: public class CompositeText implements ComponentText { private TypeComponent type; private String value; private final List childComponents; private CompositeText() { childComponents =…
West Side
  • 166
  • 3
  • 10
-1
votes
2 answers

How to get value from VOID type method?

At the time of developing the code in c# winforms, i have a problem.. In composite pattern, code is like //Interface interface Usage { public abstract void getinfo(); public abstract void add(Usage u); } //Leaf class…
kik
  • 247
  • 1
  • 5
  • 15
-1
votes
1 answer

anonymous struct fail to compile with composite literal

Just 2 lines of code: var v4 interface{}=strcut{x int}(1) // line 14 var v5 interface{}=&strcut{x int}(1) // line 15 Go prints: my_test.go:14:29: missing ',' in composite literal my_test.go:15:30: missing ',' in composite literal So how to fix it?…
Troskyvs
  • 7,537
  • 7
  • 47
  • 115
-1
votes
2 answers

How to fix "Access violation reading" error?

I set up a "parent class pointer" vector with size 2 to store its "derived class" address but seem like this vector only stores final address no matter how many address i added, so its cause "Access violation reading" problem. By the way i used…
Nguyen Bot
  • 13
  • 5
-1
votes
1 answer

How can we implement composite and visitor pattern together in java?

I am trying to combine both pattern in java, but I did not understant how to make both of them nested?
-1
votes
1 answer

How to dynamically choose the return type of the operator [ ] in composite design pattern?

First of all, I want to point out that it is the first time I am using dynamic polymorphism and the composite design pattern. I would like to use the composite design pattern to create a class Tree which is able to take different objects of the…
Garo
  • 111
  • 7
-1
votes
3 answers

What are these methods for?

I am doing a homework (composite classes on calculating the distance between two points. I have classes (Line, Point and Main). I have to use the methods my teacher designed on UML. However, i found that i am able to calculate the distance without…
Kirbbbb
  • 133
  • 1
  • 9
-1
votes
1 answer

how can i insert a composite component (menu of menus) in my database

I am implementing the Composite Design pattern and I need to insert a menu in the database but the menu may consist of other menus and menu items so when I tried to insert them recursively, I got an error because the submenu and sub items need to…
-1
votes
2 answers

Refactor class that has multiple methods with the same signature

I have a class with multiple methods that have the same signature: string MethodA(int id); string MethodB(int id); string MethodC(int id); The implementation of these methods differs obviously, but I'm trying to make this more SOLID. I got a long…
stefjnl
  • 732
  • 3
  • 14
  • 31
-1
votes
1 answer

Recursive callback to a virtual method

I'm implementing the composite design pattern and I notice that I have many traversals with code duplication. For example: class Composite extends BaseComposite{ LinkedList objs; public BaseComposite foo(int id){ …
shinzou
  • 5,850
  • 10
  • 60
  • 124