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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com