• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Command Pattern for MVC web based

 
Pawanpreet Singh
Ranch Hand
Posts: 264
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working to make a design for developing a command pattern in MVC web based application. I am using an ActionFactory whose static method is called from ServletController. Am i doing right. Should i use static method or do i create a one time object of ActionFactory in ServletController and call it non-static public method for getting the Action per request basis.

Also could you please let me know that is command pattern(behavioural) same as Factory Pattern(creational)?
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I like this kind of thing a lot. I use something like:

This uses a static method, which is pretty common. Folks interested in maximum flexibility and testability avoid hard-coded class dependencies like CommandFactory and static methods, but that's general OO theory not specific to this problem. If you want to dig into that topic, scroll down to the OO, UML, etc. forum.

Here are some options ... I left out casting and exceptions and such for brevity ...
 
Pawanpreet Singh
Ranch Hand
Posts: 264
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot, James
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic