Skip to main content

All Questions

Filter by
Sorted by
Tagged with
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 ...
Krystian's user avatar
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 ...
Ngọc Hy's user avatar
  • 300
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 ...
user32882's user avatar
  • 5,817
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 ...
Itay Shwartz's user avatar
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 ...
Reshma's user avatar
  • 51
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-...
Robin Kreuzer's user avatar
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 ...
No-name's user avatar
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 ...
StefanKssmr's user avatar
  • 1,226
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 ...
Tom's user avatar
  • 48
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 ...
george's user avatar
  • 41
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 { ...
Marko Kraljevic's user avatar
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 ...
Guy's user avatar
  • 23
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 ...
Jeremías Rodríguez's user avatar
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 ...
bzfbr's user avatar
  • 93
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 ...
dynamitem's user avatar
  • 1,677
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 ...
Patricia's user avatar
  • 2,865
-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 ...
Mariox's user avatar
  • 15
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 ...
j2emanue's user avatar
  • 62.5k
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, ...
Aaron Miller's user avatar
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 ...
ying's user avatar
  • 628
-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?
Hüseyin Özkoç's user avatar
-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 ...
Garo's user avatar
  • 111
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 ...
user3364247's user avatar
  • 1,497
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 : ...
User48591's user avatar
  • 301
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 ...
user avatar
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: ...
Anton Wagner's user avatar
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(...
i.brod's user avatar
  • 4,563
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 ...
Ashok Ravi's user avatar
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 ...
Naive Developer's user avatar
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 ...
Daniel Viglione's user avatar
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 ...
zar's user avatar
  • 12.2k
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(). ...
Cranio's user avatar
  • 9,807
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!
elena's user avatar
  • 909
-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 ...
stefjnl's user avatar
  • 732
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 ...
kvway's user avatar
  • 494
-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> ...
shinzou's user avatar
  • 6,182
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?
david benalal's user avatar
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 ...
hank7v's user avatar
  • 31
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 ...
Dolis's user avatar
  • 335
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. ...
mk62's user avatar
  • 9
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 ...
rg1176's user avatar
  • 51
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 ...
mpj's user avatar
  • 357
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 { ...
Sudhanshu Mittal's user avatar
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., ...
user2514157's user avatar
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 ...
Adam1980's user avatar
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 ...
erik p's user avatar
  • 422
-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 ...
user avatar
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?
user avatar
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 ...
Scott's user avatar
  • 455
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() { ... } } ...
Signum's user avatar
  • 875