Ok, this is kinda dumb. I'm trying to wrap my head around the use of the MVC and Command Patterns. The questions basically concern where to place code.
In the MVC pattern, where are the Commands instantiated? Are they created by the Controller, or are they contained fully in the Model or neither.
BTW, Should one be using the Command pattern if there is no need of undo/redo.
Regards
MVC Commands are used to break up the controller layer of a Liferay MVC application into smaller, more digestible code chunks. Sometimes you'll want to override an MVC command, whether it's in a Liferay application or another Liferay MVC application whose source code you don't own.
The Model View Controller (MVC) design pattern specifies that an application consist of a data model, presentation information, and control information. The pattern requires that each of these be separated into different objects. MVC is more of an architectural pattern, but not for complete application.
In object-oriented programming, the command pattern is a behavioral design pattern in which an object is used to encapsulate all information needed to perform an action or trigger an event at a later time. This information includes the method name, the object that owns the method and values for the method parameters.
The Model-View-Controller (MVC) is an architectural pattern which separates an application into three main groups of components: Models, Views, and Controllers. MVC is abbreviated as Model View Controller is a design pattern created for developing applications specifically web applications.
While there are many variations based on the needs/complexity of an application, you typically find them implemented in the Controller. Here is a great article on using the Command pattern in an MVC architecture. I'm not sure what type of application you are building, but here are a few more resources that show implementations on different application stacks.
http://java.sun.com/blueprints/guidelines/designing_enterprise_applications_2e/web-tier/web-tier5.html
http://msdn.microsoft.com/en-us/library/ff647590.aspx
http://www.phpwact.org/pattern/model_view_controller
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With