wood burning stoves 2.0*
The moose likes OO, Patterns, UML and Refactoring and the fly likes To MVC or not to MVC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "To MVC or not to MVC" Watch "To MVC or not to MVC" New topic
Author

To MVC or not to MVC

Alex Birmingham
Ranch Hand

Joined: May 22, 2008
Posts: 54
Hey all,

Having just read Head First's Design patterns, I am seeing opportunities for patterns everywhere! Would an MVC pattern be appropriate for the following situation?

- A text-based roleplaying game has a series of 'ability' objects which all implement an execute method. Said method does its ability-specific chore, talking to the subject object (the performer of the ability), target object (if applicable), and the Display class, which functions to spit the narrative out onto a jtextpane in a coherent form. -

Having just picked up JUnit, I attempted to create a test-case for some of my ability objects. This exercise quickly revealed to me just how many 'stub' or 'mock' objects I would need to create in order to perform even the simplest of tests! Especially since the ability's 'subject' and 'target' have to be given room objects, and names, and genders, etc. etc. etc.

It seems to me that this is an example of a low-cohesion highly-coupled program? Or is it simply permissable in a large-ish program for a lot of classes to know about each other simply due to the nature of how complex things get? (For example, using once again the RPG, the abilities need to know about the creatures performing them, the static algorithmic classes which perform the math, and the display class in order to transmit a narrative of the ability to the player, if said player is in the room). In this example, it makes sense for the abilities to know about the math involved, and potentially even the creatures, but wouldnt a liasion 'model' component be helpful for communicating with the 'view' component?

Or perhaps not? Would the passing of a string to a 'model' before going to the 'view' merely be an unnecessary formality?

Any thoughts/feedback welcome! Thanks!


- SCJA 1.0
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: To MVC or not to MVC
 
Similar Threads
Just finished my first GUI program (a planner application) ... could you give me feedback?
Java MMO: Sharing data between multiple clients and server
Design Pattern for GUI implementation
MVC question - where's the model?
Your opinion on MVC please.