• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

To MVC or not to MVC

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
reply
    Bookmark Topic Watch Topic
  • New Topic