All Questions
Tagged with composite design-patterns
158 questions
1
vote
1
answer
234
views
General Protection Error after second 'New Downlaod' or 'Online Change'
I'm trying to build a composite pattern in Twincat 3.1.
Everything seems to work fine on Activate Configuration and the first new download or online change. The second new download causes General ...
2
votes
1
answer
90
views
Can I call this an implementation of the Composite Pattern
I have this design which I self-proclaim to be Composite Pattern, though I'm not entirely sure about that. So I'm aksing for your statement on this.
This is the interface which collectively describes ...
0
votes
2
answers
450
views
Is the relationship between a View and a Controller in MVC really just a Strategy pattern?
The Gang of Four book states the following:
[...] The main relationships in MVC are given by the Observer, Composite and Strategy design patterns.
The best example of this I could find was this ...
0
votes
0
answers
103
views
Does the composite design patterm adhere the principles of SOLID (spacialy the L and the I)? [duplicate]
Does the composite design template adhere to the principles of solid?
if all the compositing method are declared at the component its violation of the Interface Segregation Principle. if compositing ...
4
votes
2
answers
1k
views
Decorator design pattern with Composite Design pattern
I understand the composite design pattern and the decorator design pattern and their uses. Can we have a case where we have to use them together? How would the class diagram for such a scenario look ...
1
vote
1
answer
118
views
How to composite using-by objects (real world example)
Hey i have question with a real word example.
Its related to my two other, but not really answered questions here:
https://softwareengineering.stackexchange.com/questions/423392/no-trivial-god-class-...
0
votes
1
answer
49
views
Composite pattern simultaneous task
I have been reading about the composite pattern but I don't know if fits in my problem, actually I need to manage a hierarchy of events like, for example, send an email, send SMS, and of course, these ...
1
vote
1
answer
152
views
How to avoid downcasting in composite pattern
I use a composite pattern to represent a mechanical network, which describes the mechanical behavior of a material, see e.g. the Maxwell-Wiechert model, a spring in parallel with n Maxwell Elements. A ...
2
votes
1
answer
338
views
Iterating over a composite
In the Head First Design Patterns book, the authors describe using an iterator to traverse over composite data structures. They provide some sample code which, when executed, prints out a series of ...
1
vote
2
answers
231
views
determining whether the composite pattern is used properly or not
I am trying to use the composite design pattern in Java. However, I am not sure if I have used it validly/correctly. Is the code below a valid/correct use of the composite design pattern? I have a ...
0
votes
2
answers
678
views
Best way to serialize composite - (design pattern)
I have following java code that is implementation of Composite Design pattern:
//composite designed for type safety (all Leaf-only operations only in leaf)
interface Component extends Visitable {
...
0
votes
1
answer
331
views
Exception safety in the composite pattern
I used the composite pattern to represent devices, which I would like to shut down before killing their power (calling their dtor).
I ran into a problem trying to group the devices, especially ...
2
votes
1
answer
108
views
Operation in composite design pattern vs add a new visitor in visitor design pattern
Eric Gamma's Design Patterns book explains that a composite structure may declare operations:
Such operations are propagated recursively by non-leaf operators.
On the other hand, we may get the same ...
2
votes
0
answers
140
views
C++ Builder combined with Visitor
I am designing a GUI Framework based on Composite pattern (Window class inherits from UIComponent class)
I need to implement a class that will create a window consisting of some UIComponents. I think ...
1
vote
2
answers
435
views
Modified Composite pattern / Food, Recipes and Subrecipes
I'm having troubles implementing the Composite Pattern correctly (to make it the most efficient).
There are two entities involved: Basic Food and Recipes. They are to be parsed from a CSV file.
A ...
0
votes
0
answers
154
views
Composite Pattern: Is the root a simple Composite?
To implement the Composite pattern in Java I have an abstract class Component with the functions getChild(int i), add(Component c), remove(Component c), forAllDo() and getChildren().
It is ...
-2
votes
1
answer
235
views
Example Composite Design Pattern - Genealogical Tree
I would like to model a genealogical tree with the composite pattern. For simplicity I am only interested:
to the marriage relationship between two people
to the paternity relationship between a ...
4
votes
4
answers
7k
views
Composite Design pattern - how to create calculator
I want to explore the difference between recursion approach and composite design pattern. Composite design pattern reminds me of a tree structure. So if I have to write up how it would look in a class ...
0
votes
3
answers
1k
views
Can the Composite Design pattern avoid a Collection (List, HashTable) data structure?
I want a full comprehension of all possible types of the Composite Design Pattern when looking at code. In this code I have a composite object PeanutButterAndJellySandwich which contains Bread, ...
3
votes
3
answers
966
views
How to cut down boilerplate code in composite/decorate pattern
In composite/decorate patter, the outer container overrides some methods to change the behavior, but have to delegate to sub-component for the rest of methods.
ex: class A has 10 methods, class B ...
-1
votes
1
answer
2k
views
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
48
views
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 ...
1
vote
0
answers
143
views
Inherited Composite Class
I am working on a pattern and would like to know if this is a good practice to follow - I have class A as super class and classes B and C are child classes (inherited from class A). I want to build a ...
0
votes
1
answer
280
views
Inheritance in generic composite pattern [duplicate]
For what I want to achieve I ended up with some kind of generic composite pattern.
public abstract class Component
{
}
public abstract class Composite<ChildType> : Component where ChildType : ...
0
votes
1
answer
35
views
Composite Pattern with Restriction
The image is an example of Composite Pattern.
However I have a restriction, that is that ConcreteComponent1 can only have ONE ConcreteComponent2.
Any idea how I can achieve that?
Thanks!
(Sorry ...
1
vote
1
answer
722
views
Which design patterns are used in this example?
The following example is an older exam question I am trying to understand. The question is: Which design patterns are used in the following class chart?
In my opinion there is the composite pattern:
...
1
vote
0
answers
108
views
Javascript: Getting the parent object, in OOP composite pattern
My program implements the composite pattern, that looks more or less like that:
class Selector{
constructor(){
this.selectors=[]
}
addSelector(selector){
this.selectors.push(...
1
vote
0
answers
405
views
how to use flyweight pattern in composite pattern
I'm following O'Reilly C# Design Pattern book so I try to do some own exercise to implement some following design patterns but I can't get expect output to clear my doubt (what are patterns should i ...
0
votes
1
answer
233
views
Increasing elements in a data structure that follows the Composite pattern
I have often read/heard that the composite pattern is a good solution to represent hierarchical data structures like binary trees, which it is great to explain this pattern because internal nodes are ...
2
votes
1
answer
496
views
black vs white arrows in defining relationships in design patterns
I am reviewing this guide on different design patterns. Currently, I am reviewing the Composite Design Pattern. Author provides a graph defining the relationship between different components. When I ...
3
votes
4
answers
1k
views
Composite pattern with variations in classes
I have a situation where class A, B, and C, all are derived from X to make a composite pattern.
Now A, B, and C are very similar but they do have different internal attributes. My question is how do ...
2
votes
1
answer
2k
views
Which is the Design Pattern of Fallback services in an array
Let's suppose I've seen a FallbackCompositeService that is used by a client object to obtain a result with a fallback mechanism.
It implements a FallbackServiceInterface with a method doSomething().
...
0
votes
2
answers
197
views
What is the difference between a composite pattern expressed with arrow point to component and one without?
I am designing a program and I would like to make use of the composite pattern. I have noticed that there are two ways of expressing it:
and
What is the difference between the two?
Thank you!
-1
votes
2
answers
437
views
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 ...
0
votes
1
answer
881
views
Composite design pattern definition
In the book Design Patterns : Elements of Reusable Object-Oriented Software, It says:
"The composite design pattern composes objects into tree structures to represent part-whole hierarchies."
In ...
-1
votes
1
answer
80
views
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<BaseComposite> ...
0
votes
1
answer
108
views
Projects that use composite pattern?
what kind of projects use the composite pattern? How am I supposed to know what project is using the composite pattern?
0
votes
1
answer
527
views
Combining Composite and Mediator Pattern
I've seen few attempts of implementing such a combination. But my question is if combining these two Patterns is somehow recommended. As it seems to me that the Mediator, by controlling the behaviour ...
2
votes
2
answers
871
views
using Composite Pattern to count the number of people in the world
I'm trying to make a Composite Pattern that counts the number of people in the world, the continent, the state... sorry no state but country my bad sorry
Here is the pattern that I follow:
I did ...
0
votes
1
answer
708
views
Java - implement iterator with strategy
I am trying to implement a custom iterator for a composite class and use different strategies in the iterator implementation depending on how the client wants to traverse the composite structure.
...
2
votes
2
answers
277
views
Persist a composite pattern implementation - ruby on rails
does anyone has a good end-to-end example of how to persist to the database a text book composite pattern from GoF such as the one below?
Component base class:
class Task
attr_reader :name
def ...
0
votes
2
answers
2k
views
Design Patterns: Builder + Decorator + Composite
I have to do a project that uses at least three design patterns. At first time I tried to use builder pattern with decorator pattern but my teacher told me that I should connect both of them with ...
0
votes
0
answers
365
views
Relational model for java composite pattern
I have classes that follow a composite pattern relationship for which I need to create the relational data model for Oracle database.
The (java) classes are as below -
class AbstractEmployee {
...
1
vote
0
answers
139
views
Java Composite Design Pattern using LinkedHashSet
My goal is to create an object using the Composite Design Pattern that can be marshaled into XML using JAXB. In addition, in my case, it seems desirable for the composite component to use a Set (e.g., ...
0
votes
1
answer
71
views
Loosely coupling composite object nodes and their dependencies
Lets say I have a set of conditional requirements that can be nested inside of each other in a tree like structure, but all of the requirements need to communicate with different subsystems to find ...
0
votes
0
answers
719
views
(Java) Composite Pattern AND Visitor Pattern or only Visitor Pattern in use here?
Sorry if this question has been asked before. I could not find a question that addressed EXACTLY this situation I'm in. The closest I've come to finding a satisfactory answer is someone mentioning ...
-1
votes
1
answer
165
views
Indexing getter composite pattern java
I have implemented this model with Composite pattern in Java:
I would like to know how I can access to the leafs of these tree using an index getter. For example if I have a List of Element, get the ...
3
votes
2
answers
773
views
Access to the leafs of Composite pattern Java
I implement the Composite pattern for represent a tree of elements like in the picture:
But how I can access to the leafs of this tree, like a List of Leaf. Should I implement Visitor?
0
votes
1
answer
925
views
Iterator Pattern implemented inside of Composite Pattern
I am working on a project for Design Patterns, and I am trying to implement an iterator within my composite base class. The problem though is that I am getting errors from the compiler not knowing ...
2
votes
1
answer
496
views
Composite design pattern: how to pass results from one component into another?
I have the following code:
interface IService
{
void Execute();
}
class ServiceA : IService
{
public void Execute() { ... }
}
class ServiceB : IService
{
public void Execute() { ... }
}
...