How to solve the problem of too many methods in the command processor in command pattern
We plan to apply the command pattern in our process management project: there are
- a
Commandinterface to implement - a
CommandProcessor, which truly execute some task
The CommandProcessor is passed to the Command instance through constructor so that the execute() method in Command will eventually trigger the true execution in CommandProcessor
So the code of CommandProcessor looks like this:
public class CommandProcessor {
public doWork1() {
//implementation
}
public doWork2() {
//implementation
}
public doWork3() {
//implementation
}
...
public doWork200() {
//implementation
}
}
As the code snippet indicates, the downside of command pattern in our use case is there might be hundreds of commands and thus the CommandProcessor might be difficult to maintain in the long term. So how to resolve this drawback?
refactoring command-pattern
add a comment |
We plan to apply the command pattern in our process management project: there are
- a
Commandinterface to implement - a
CommandProcessor, which truly execute some task
The CommandProcessor is passed to the Command instance through constructor so that the execute() method in Command will eventually trigger the true execution in CommandProcessor
So the code of CommandProcessor looks like this:
public class CommandProcessor {
public doWork1() {
//implementation
}
public doWork2() {
//implementation
}
public doWork3() {
//implementation
}
...
public doWork200() {
//implementation
}
}
As the code snippet indicates, the downside of command pattern in our use case is there might be hundreds of commands and thus the CommandProcessor might be difficult to maintain in the long term. So how to resolve this drawback?
refactoring command-pattern
There are several ways to "resolve this drawback," but I think the whole point of a command processor would be to delegate the work to other classes anyway, (much like a controller does in MVC), so I'm not convinced that "lots of methods" in a command processor is a real problem.
– Robert Harvey♦
Jan 2 at 15:44
One way is to rethink your API. Do you really need 300 work methods, or do you just need a better design, one that works at a somewhat higher level of abstraction?
– Robert Harvey♦
Jan 2 at 15:45
Thanks :) delegation seems to be good. But are there any other solution as well?
– Rui
Jan 2 at 15:49
You only need one.
– Robert Harvey♦
Jan 2 at 15:49
add a comment |
We plan to apply the command pattern in our process management project: there are
- a
Commandinterface to implement - a
CommandProcessor, which truly execute some task
The CommandProcessor is passed to the Command instance through constructor so that the execute() method in Command will eventually trigger the true execution in CommandProcessor
So the code of CommandProcessor looks like this:
public class CommandProcessor {
public doWork1() {
//implementation
}
public doWork2() {
//implementation
}
public doWork3() {
//implementation
}
...
public doWork200() {
//implementation
}
}
As the code snippet indicates, the downside of command pattern in our use case is there might be hundreds of commands and thus the CommandProcessor might be difficult to maintain in the long term. So how to resolve this drawback?
refactoring command-pattern
We plan to apply the command pattern in our process management project: there are
- a
Commandinterface to implement - a
CommandProcessor, which truly execute some task
The CommandProcessor is passed to the Command instance through constructor so that the execute() method in Command will eventually trigger the true execution in CommandProcessor
So the code of CommandProcessor looks like this:
public class CommandProcessor {
public doWork1() {
//implementation
}
public doWork2() {
//implementation
}
public doWork3() {
//implementation
}
...
public doWork200() {
//implementation
}
}
As the code snippet indicates, the downside of command pattern in our use case is there might be hundreds of commands and thus the CommandProcessor might be difficult to maintain in the long term. So how to resolve this drawback?
refactoring command-pattern
refactoring command-pattern
asked Jan 2 at 15:42
RuiRui
1,11311541
1,11311541
There are several ways to "resolve this drawback," but I think the whole point of a command processor would be to delegate the work to other classes anyway, (much like a controller does in MVC), so I'm not convinced that "lots of methods" in a command processor is a real problem.
– Robert Harvey♦
Jan 2 at 15:44
One way is to rethink your API. Do you really need 300 work methods, or do you just need a better design, one that works at a somewhat higher level of abstraction?
– Robert Harvey♦
Jan 2 at 15:45
Thanks :) delegation seems to be good. But are there any other solution as well?
– Rui
Jan 2 at 15:49
You only need one.
– Robert Harvey♦
Jan 2 at 15:49
add a comment |
There are several ways to "resolve this drawback," but I think the whole point of a command processor would be to delegate the work to other classes anyway, (much like a controller does in MVC), so I'm not convinced that "lots of methods" in a command processor is a real problem.
– Robert Harvey♦
Jan 2 at 15:44
One way is to rethink your API. Do you really need 300 work methods, or do you just need a better design, one that works at a somewhat higher level of abstraction?
– Robert Harvey♦
Jan 2 at 15:45
Thanks :) delegation seems to be good. But are there any other solution as well?
– Rui
Jan 2 at 15:49
You only need one.
– Robert Harvey♦
Jan 2 at 15:49
There are several ways to "resolve this drawback," but I think the whole point of a command processor would be to delegate the work to other classes anyway, (much like a controller does in MVC), so I'm not convinced that "lots of methods" in a command processor is a real problem.
– Robert Harvey♦
Jan 2 at 15:44
There are several ways to "resolve this drawback," but I think the whole point of a command processor would be to delegate the work to other classes anyway, (much like a controller does in MVC), so I'm not convinced that "lots of methods" in a command processor is a real problem.
– Robert Harvey♦
Jan 2 at 15:44
One way is to rethink your API. Do you really need 300 work methods, or do you just need a better design, one that works at a somewhat higher level of abstraction?
– Robert Harvey♦
Jan 2 at 15:45
One way is to rethink your API. Do you really need 300 work methods, or do you just need a better design, one that works at a somewhat higher level of abstraction?
– Robert Harvey♦
Jan 2 at 15:45
Thanks :) delegation seems to be good. But are there any other solution as well?
– Rui
Jan 2 at 15:49
Thanks :) delegation seems to be good. But are there any other solution as well?
– Rui
Jan 2 at 15:49
You only need one.
– Robert Harvey♦
Jan 2 at 15:49
You only need one.
– Robert Harvey♦
Jan 2 at 15:49
add a comment |
1 Answer
1
active
oldest
votes
This does not feel like the command pattern to me. the design you have highlighted does not hide the implementation detail from the caller. It puts all the logic for which method to call with the caller rather than it being hidden behind an interface.
The main reason for the Command pattern is the caller of the command does not need to know anything at all about what the command is, what it does, all of that is encapsulated in the command itself.
I feel your fears about having 200 command methods have merit. Firstly consider what happens when you add, remove or change the signiture of any of these work methods. Not only do you need to change the interface but also all the concrete classes that implement that interface, and all the locations where the interface is called.
Typically the command pattern has one execute interface, see this wikipedia article for a description of the command_pattern
As @robert mentioned in your comments i think you should rethink your API.
Edit
After a good conversation with @Rui I better understand the question and have the following to say.
Whilst I misunderstood the original question I'm still prepared to stand by the statement that a redesign is needed. Whilst the command pattern is being followed I dont think the spirit of the pattern is. The object passed to the commands (the commandProcessor) is the receiver of the commands actions, but this does not look like a proper object. Obviously I lack context but for me any object that ends in -er raises big flags as not really being an object, but more a collection of methods that act on someone elses data.
Here is a good little write up with some links. I often find that classes like managers, processors or helpers go hand in hand with an Anemic Domain Model. Maybe you are on the beginnings of the right track and i would challange you to look at that commandProcessor and see if its not actually a number of descrete objects that can encapsulate their own data and methods.
Thanks for your answer, but I don't understand why you told this is not command pattern: the implementation ofCommandinterface will include theCommandProcessorin the constructor so that theCommand.execute()method will callCommandProcessor.doWork...(), isn't this command pattern? However, there has to be a class where there are all the implementations of all command execution, i.e.,CommandProcessor
– Rui
Jan 3 at 9:33
I see, I missed that detail, my mistake. When i think about this again it just feels like the design outlined violates the spirit of the command pattern. If you are passing in an object (the command processor) to all the different commands then what do the commands have responsibility for? what do they actually do? if its just to delegate to the command processor I get the feeling that the command pattern is not what you are looking for.
– Damo
Jan 3 at 17:59
Also do the dowork methods share state or logic? I guess my question is does doWork1 have to be in the same file / class as doWork2 etc?
– Damo
Jan 3 at 18:03
btw, the actual actions of commands is passed to theCommandProcessoris done so according to the exactly sample code in the wikipedia link you sent, where the actual actions of theLightare all in theLightclass, so theLightper se. is a command processor, isn't it?
– Rui
Jan 3 at 18:42
100% correct but the difference here is that the light is an object in OO terms, a command processor is not really an object. I've amended my answer to give some more detail on this.
– Damo
Jan 3 at 21:56
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54009165%2fhow-to-solve-the-problem-of-too-many-methods-in-the-command-processor-in-command%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
This does not feel like the command pattern to me. the design you have highlighted does not hide the implementation detail from the caller. It puts all the logic for which method to call with the caller rather than it being hidden behind an interface.
The main reason for the Command pattern is the caller of the command does not need to know anything at all about what the command is, what it does, all of that is encapsulated in the command itself.
I feel your fears about having 200 command methods have merit. Firstly consider what happens when you add, remove or change the signiture of any of these work methods. Not only do you need to change the interface but also all the concrete classes that implement that interface, and all the locations where the interface is called.
Typically the command pattern has one execute interface, see this wikipedia article for a description of the command_pattern
As @robert mentioned in your comments i think you should rethink your API.
Edit
After a good conversation with @Rui I better understand the question and have the following to say.
Whilst I misunderstood the original question I'm still prepared to stand by the statement that a redesign is needed. Whilst the command pattern is being followed I dont think the spirit of the pattern is. The object passed to the commands (the commandProcessor) is the receiver of the commands actions, but this does not look like a proper object. Obviously I lack context but for me any object that ends in -er raises big flags as not really being an object, but more a collection of methods that act on someone elses data.
Here is a good little write up with some links. I often find that classes like managers, processors or helpers go hand in hand with an Anemic Domain Model. Maybe you are on the beginnings of the right track and i would challange you to look at that commandProcessor and see if its not actually a number of descrete objects that can encapsulate their own data and methods.
Thanks for your answer, but I don't understand why you told this is not command pattern: the implementation ofCommandinterface will include theCommandProcessorin the constructor so that theCommand.execute()method will callCommandProcessor.doWork...(), isn't this command pattern? However, there has to be a class where there are all the implementations of all command execution, i.e.,CommandProcessor
– Rui
Jan 3 at 9:33
I see, I missed that detail, my mistake. When i think about this again it just feels like the design outlined violates the spirit of the command pattern. If you are passing in an object (the command processor) to all the different commands then what do the commands have responsibility for? what do they actually do? if its just to delegate to the command processor I get the feeling that the command pattern is not what you are looking for.
– Damo
Jan 3 at 17:59
Also do the dowork methods share state or logic? I guess my question is does doWork1 have to be in the same file / class as doWork2 etc?
– Damo
Jan 3 at 18:03
btw, the actual actions of commands is passed to theCommandProcessoris done so according to the exactly sample code in the wikipedia link you sent, where the actual actions of theLightare all in theLightclass, so theLightper se. is a command processor, isn't it?
– Rui
Jan 3 at 18:42
100% correct but the difference here is that the light is an object in OO terms, a command processor is not really an object. I've amended my answer to give some more detail on this.
– Damo
Jan 3 at 21:56
add a comment |
This does not feel like the command pattern to me. the design you have highlighted does not hide the implementation detail from the caller. It puts all the logic for which method to call with the caller rather than it being hidden behind an interface.
The main reason for the Command pattern is the caller of the command does not need to know anything at all about what the command is, what it does, all of that is encapsulated in the command itself.
I feel your fears about having 200 command methods have merit. Firstly consider what happens when you add, remove or change the signiture of any of these work methods. Not only do you need to change the interface but also all the concrete classes that implement that interface, and all the locations where the interface is called.
Typically the command pattern has one execute interface, see this wikipedia article for a description of the command_pattern
As @robert mentioned in your comments i think you should rethink your API.
Edit
After a good conversation with @Rui I better understand the question and have the following to say.
Whilst I misunderstood the original question I'm still prepared to stand by the statement that a redesign is needed. Whilst the command pattern is being followed I dont think the spirit of the pattern is. The object passed to the commands (the commandProcessor) is the receiver of the commands actions, but this does not look like a proper object. Obviously I lack context but for me any object that ends in -er raises big flags as not really being an object, but more a collection of methods that act on someone elses data.
Here is a good little write up with some links. I often find that classes like managers, processors or helpers go hand in hand with an Anemic Domain Model. Maybe you are on the beginnings of the right track and i would challange you to look at that commandProcessor and see if its not actually a number of descrete objects that can encapsulate their own data and methods.
Thanks for your answer, but I don't understand why you told this is not command pattern: the implementation ofCommandinterface will include theCommandProcessorin the constructor so that theCommand.execute()method will callCommandProcessor.doWork...(), isn't this command pattern? However, there has to be a class where there are all the implementations of all command execution, i.e.,CommandProcessor
– Rui
Jan 3 at 9:33
I see, I missed that detail, my mistake. When i think about this again it just feels like the design outlined violates the spirit of the command pattern. If you are passing in an object (the command processor) to all the different commands then what do the commands have responsibility for? what do they actually do? if its just to delegate to the command processor I get the feeling that the command pattern is not what you are looking for.
– Damo
Jan 3 at 17:59
Also do the dowork methods share state or logic? I guess my question is does doWork1 have to be in the same file / class as doWork2 etc?
– Damo
Jan 3 at 18:03
btw, the actual actions of commands is passed to theCommandProcessoris done so according to the exactly sample code in the wikipedia link you sent, where the actual actions of theLightare all in theLightclass, so theLightper se. is a command processor, isn't it?
– Rui
Jan 3 at 18:42
100% correct but the difference here is that the light is an object in OO terms, a command processor is not really an object. I've amended my answer to give some more detail on this.
– Damo
Jan 3 at 21:56
add a comment |
This does not feel like the command pattern to me. the design you have highlighted does not hide the implementation detail from the caller. It puts all the logic for which method to call with the caller rather than it being hidden behind an interface.
The main reason for the Command pattern is the caller of the command does not need to know anything at all about what the command is, what it does, all of that is encapsulated in the command itself.
I feel your fears about having 200 command methods have merit. Firstly consider what happens when you add, remove or change the signiture of any of these work methods. Not only do you need to change the interface but also all the concrete classes that implement that interface, and all the locations where the interface is called.
Typically the command pattern has one execute interface, see this wikipedia article for a description of the command_pattern
As @robert mentioned in your comments i think you should rethink your API.
Edit
After a good conversation with @Rui I better understand the question and have the following to say.
Whilst I misunderstood the original question I'm still prepared to stand by the statement that a redesign is needed. Whilst the command pattern is being followed I dont think the spirit of the pattern is. The object passed to the commands (the commandProcessor) is the receiver of the commands actions, but this does not look like a proper object. Obviously I lack context but for me any object that ends in -er raises big flags as not really being an object, but more a collection of methods that act on someone elses data.
Here is a good little write up with some links. I often find that classes like managers, processors or helpers go hand in hand with an Anemic Domain Model. Maybe you are on the beginnings of the right track and i would challange you to look at that commandProcessor and see if its not actually a number of descrete objects that can encapsulate their own data and methods.
This does not feel like the command pattern to me. the design you have highlighted does not hide the implementation detail from the caller. It puts all the logic for which method to call with the caller rather than it being hidden behind an interface.
The main reason for the Command pattern is the caller of the command does not need to know anything at all about what the command is, what it does, all of that is encapsulated in the command itself.
I feel your fears about having 200 command methods have merit. Firstly consider what happens when you add, remove or change the signiture of any of these work methods. Not only do you need to change the interface but also all the concrete classes that implement that interface, and all the locations where the interface is called.
Typically the command pattern has one execute interface, see this wikipedia article for a description of the command_pattern
As @robert mentioned in your comments i think you should rethink your API.
Edit
After a good conversation with @Rui I better understand the question and have the following to say.
Whilst I misunderstood the original question I'm still prepared to stand by the statement that a redesign is needed. Whilst the command pattern is being followed I dont think the spirit of the pattern is. The object passed to the commands (the commandProcessor) is the receiver of the commands actions, but this does not look like a proper object. Obviously I lack context but for me any object that ends in -er raises big flags as not really being an object, but more a collection of methods that act on someone elses data.
Here is a good little write up with some links. I often find that classes like managers, processors or helpers go hand in hand with an Anemic Domain Model. Maybe you are on the beginnings of the right track and i would challange you to look at that commandProcessor and see if its not actually a number of descrete objects that can encapsulate their own data and methods.
edited Jan 3 at 21:56
answered Jan 3 at 9:25
DamoDamo
98611126
98611126
Thanks for your answer, but I don't understand why you told this is not command pattern: the implementation ofCommandinterface will include theCommandProcessorin the constructor so that theCommand.execute()method will callCommandProcessor.doWork...(), isn't this command pattern? However, there has to be a class where there are all the implementations of all command execution, i.e.,CommandProcessor
– Rui
Jan 3 at 9:33
I see, I missed that detail, my mistake. When i think about this again it just feels like the design outlined violates the spirit of the command pattern. If you are passing in an object (the command processor) to all the different commands then what do the commands have responsibility for? what do they actually do? if its just to delegate to the command processor I get the feeling that the command pattern is not what you are looking for.
– Damo
Jan 3 at 17:59
Also do the dowork methods share state or logic? I guess my question is does doWork1 have to be in the same file / class as doWork2 etc?
– Damo
Jan 3 at 18:03
btw, the actual actions of commands is passed to theCommandProcessoris done so according to the exactly sample code in the wikipedia link you sent, where the actual actions of theLightare all in theLightclass, so theLightper se. is a command processor, isn't it?
– Rui
Jan 3 at 18:42
100% correct but the difference here is that the light is an object in OO terms, a command processor is not really an object. I've amended my answer to give some more detail on this.
– Damo
Jan 3 at 21:56
add a comment |
Thanks for your answer, but I don't understand why you told this is not command pattern: the implementation ofCommandinterface will include theCommandProcessorin the constructor so that theCommand.execute()method will callCommandProcessor.doWork...(), isn't this command pattern? However, there has to be a class where there are all the implementations of all command execution, i.e.,CommandProcessor
– Rui
Jan 3 at 9:33
I see, I missed that detail, my mistake. When i think about this again it just feels like the design outlined violates the spirit of the command pattern. If you are passing in an object (the command processor) to all the different commands then what do the commands have responsibility for? what do they actually do? if its just to delegate to the command processor I get the feeling that the command pattern is not what you are looking for.
– Damo
Jan 3 at 17:59
Also do the dowork methods share state or logic? I guess my question is does doWork1 have to be in the same file / class as doWork2 etc?
– Damo
Jan 3 at 18:03
btw, the actual actions of commands is passed to theCommandProcessoris done so according to the exactly sample code in the wikipedia link you sent, where the actual actions of theLightare all in theLightclass, so theLightper se. is a command processor, isn't it?
– Rui
Jan 3 at 18:42
100% correct but the difference here is that the light is an object in OO terms, a command processor is not really an object. I've amended my answer to give some more detail on this.
– Damo
Jan 3 at 21:56
Thanks for your answer, but I don't understand why you told this is not command pattern: the implementation of
Command interface will include the CommandProcessor in the constructor so that the Command.execute() method will call CommandProcessor.doWork...(), isn't this command pattern? However, there has to be a class where there are all the implementations of all command execution, i.e., CommandProcessor– Rui
Jan 3 at 9:33
Thanks for your answer, but I don't understand why you told this is not command pattern: the implementation of
Command interface will include the CommandProcessor in the constructor so that the Command.execute() method will call CommandProcessor.doWork...(), isn't this command pattern? However, there has to be a class where there are all the implementations of all command execution, i.e., CommandProcessor– Rui
Jan 3 at 9:33
I see, I missed that detail, my mistake. When i think about this again it just feels like the design outlined violates the spirit of the command pattern. If you are passing in an object (the command processor) to all the different commands then what do the commands have responsibility for? what do they actually do? if its just to delegate to the command processor I get the feeling that the command pattern is not what you are looking for.
– Damo
Jan 3 at 17:59
I see, I missed that detail, my mistake. When i think about this again it just feels like the design outlined violates the spirit of the command pattern. If you are passing in an object (the command processor) to all the different commands then what do the commands have responsibility for? what do they actually do? if its just to delegate to the command processor I get the feeling that the command pattern is not what you are looking for.
– Damo
Jan 3 at 17:59
Also do the dowork methods share state or logic? I guess my question is does doWork1 have to be in the same file / class as doWork2 etc?
– Damo
Jan 3 at 18:03
Also do the dowork methods share state or logic? I guess my question is does doWork1 have to be in the same file / class as doWork2 etc?
– Damo
Jan 3 at 18:03
btw, the actual actions of commands is passed to the
CommandProcessor is done so according to the exactly sample code in the wikipedia link you sent, where the actual actions of the Light are all in the Light class, so the Light per se. is a command processor, isn't it?– Rui
Jan 3 at 18:42
btw, the actual actions of commands is passed to the
CommandProcessor is done so according to the exactly sample code in the wikipedia link you sent, where the actual actions of the Light are all in the Light class, so the Light per se. is a command processor, isn't it?– Rui
Jan 3 at 18:42
100% correct but the difference here is that the light is an object in OO terms, a command processor is not really an object. I've amended my answer to give some more detail on this.
– Damo
Jan 3 at 21:56
100% correct but the difference here is that the light is an object in OO terms, a command processor is not really an object. I've amended my answer to give some more detail on this.
– Damo
Jan 3 at 21:56
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54009165%2fhow-to-solve-the-problem-of-too-many-methods-in-the-command-processor-in-command%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
There are several ways to "resolve this drawback," but I think the whole point of a command processor would be to delegate the work to other classes anyway, (much like a controller does in MVC), so I'm not convinced that "lots of methods" in a command processor is a real problem.
– Robert Harvey♦
Jan 2 at 15:44
One way is to rethink your API. Do you really need 300 work methods, or do you just need a better design, one that works at a somewhat higher level of abstraction?
– Robert Harvey♦
Jan 2 at 15:45
Thanks :) delegation seems to be good. But are there any other solution as well?
– Rui
Jan 2 at 15:49
You only need one.
– Robert Harvey♦
Jan 2 at 15:49