Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MVC Commands

 
Murat Balkan
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
So far, I have seen two mvc command designs.
One of them is you create your command classes which have only 1 execute method, that does a spesific job.(Deletecart.class, AddtoChart.class)
The other one is you create a processor with many methods regarding the current action.(ChartProcessor.class)
Which one of them do I have to use?
Thank you
 
Jeremy Hsu
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

First of all, MVC means model, view, and controller. It describes a way that you can decouple data, presentation, and logics.

On the other hand, the command pattern addresses how you can model an event/command/action using an object, so that you can pass it around. As a result, depending on your MVC design needs, you might utilize command pattern in one of your model, view, or controller. Usually, the command pattern can be used as a helper object in the controller part of the MVC design. Now on to the processor thing that you mentioned, it is actually a mediator pattern. Mediator pattern describes how different objects can send a event/command to a centralized place for processing and managing interactions between these objects. The centralized processing unit is called a mediator. Therefore, it is usually used for implementing the controller part of the MVC design because it fits what the role of a controller perfectly in a MVC design. Therefore, to answer you question, I suggest you go over the command and mediator pattern.

After that, I pretty sure you can understand that you can actually use command pattern in the mediator pattern.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic