Questions tagged [command-pattern]
12 questions
7
votes
3 answers
Design pattern: How to inject dependencies into a Command pattern
I am pretty new to programming languages and only have limited knowledge about design patterns, so I hope you can help me with the following problem:
I have an application that operates on a group of different services. One functionality of the…

Martin
- 91
- 1
- 5
5
votes
1 answer
Why do we implement the Command design pattern like this?
I trying to learn the Command design pattern, I already know how it works and where it is used, but I'm a little bit confused about the implementation.
So I know we need to set the context by passing the object to the constructor or as an argument…

Wojtek Wencel
- 238
- 1
- 9
3
votes
1 answer
Command pattern and object model integration
In a document editor application, is it better to implement the command pattern as a layer on top of the object model, or to deeply integrate it into the object model?
If commands are a layer on top, they would manipulate the object model using its…

Trillian
- 141
- 6
1
vote
1 answer
SRP, command pattern and design problem
I'm refactoring a code base to have something more easier to read and follow SRP. However I'm at the point I'm unsure what the best design is.
Currently it looks like this: A thread receives a "command" to execute. The "command" is always the same,…

Cromm
- 119
- 4
1
vote
1 answer
Abstracting common functionality for REST and CLI
I have made an application that deals with collections of images. Currently it has a REST api to add/remove images, create/clear/delete collections and a worker that can automatically fetch images from sources.
I want to make a CLI application to…

alexk745
- 21
- 3
0
votes
3 answers
Decoupling command and receiver in command pattern
I'm writing a simulation of a car that can receive commands and act on them and I'm trying to implement it using the command pattern.
class Car {
move() {
console.log('move');
}
}
interface Command {
execute():void;
}
// there can be…

Epsilon
- 9
- 1
0
votes
1 answer
Command pattern across layered architecture without shared interfaces?
I have three layers. I wish to reduce coupling between them and other modules.
I wish to use the command pattern between all layers. A command should be able to be passed from one layer to another.
For this, all layers must have implementations of…

reign
- 25
- 3
0
votes
0 answers
Designing a proof mechanism
DataModel contains a Proof that contains all the information of its integrity along with the method with which the Proof should be verified.
In this case I designed a JWS type of proof that can be generated by using a ProofGenerator object that…

Antonio Santoro
- 131
- 6
0
votes
2 answers
Is there alternative to applying events synchronously in command handler in CQRS?
I have workflow where I have complex command handlers encapsulated inside aggregate. These handlers emit some events, and then further logic based on result of these events can emit more events. Sample pseudocode of architecture:
public class…

chris
- 101
- 3
0
votes
2 answers
Combining synchronous and asynchronous commands when using the command pattern
Let's say I'm building a simple console app which has three commands:
Create category.
Download recipe from API to category.
Display all recipes in a category.
Assuming the app will grow, I use the Command design pattern to handle console…

Lucas
- 139
- 3
0
votes
1 answer
How to handle the getting of information from Model
I'm doing a Java software engineering team project in school and my team has decided on a Finance Tracker application, which contains the main components of Expense, Budget, Statistics, Suggestions and GUIPanels. Currently, the application only…

Prashin Jeevaganth
- 185
- 4
0
votes
3 answers
Intent of Command pattern?
In Elements of Reusable Object Oriented software by Erich Gamma, the intent for Command design pattern says:
Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support…

Navjot Singh
- 222
- 1
- 10