I have a large application in Java filled with independent classes which are unified in a
PlayerCharacter class. The class is intended to hold a character's data for a game called the Burning Wheel, and as a result, is unusually complex. The data in the class needs to have computations controlled by the UI, but needs to do so in particular ways for each of the objects in the class.
There are 19 objects in the class
PlayerCharacter. I've thought about condensing it down, but I'm pretty sure this wouldn't work anywhere in the application as it stands so far.
private String name = ""; private String concept = ""; private String race = ""; private int age = -1; private ArrayList<CharacterLifepath> lifepaths = new ArrayList<>(); private StatSet stats = new StatSet(); private ArrayList<Affiliation> affiliations = new ArrayList<>(); private ArrayList<Contact> contacts = new ArrayList<>(); private ArrayList<Reputation> reputations = new ArrayList<>(); //10 more lines of declarations
I've been considering this problem for some time now, and have considered multiple approaches. The problem arises primarily when data is deleted - for instance, since pretty much everything else (but not some parts!) depends upon Lifepaths, when a lifepath is deleted, nearly everything else must be recalculated. However, if a Skill is deleted, only a few things must be recalculated.
Additionally, the application must somewhere track certain values; skill points, trait points, etc. to ensure that the user is not unintentionally exceeding those values.
So my question is generally as follows: Where should everything go? What makes this easiest? There are a couple options:
- Place point total calculations in the PlayerCharacter class (but how does this generate a warning?)
- Handle all calculation outside of the PlayerCharacter class, and just use PlayerCharacter as a container for all the character's information
- Place all calculations in the PlayerCharacter class; after each item is changed, recompute the entire character. Then, if there are issues arising from deletion, throw warnings back at the UI.
I'm slightly overwhelmed by the scope of this particular class - whereas everything I've done so far has been easily broken down into small manageable chunks, this beast seems to resist being tamed. If there's a better approach to this, I'm all ears! But as of right now, I'm slightly confused, and progressing aimlessly probably won't get me anywhere. Any advice is appreciated.
I apologize if this is unclear - I'm certain I lack the software vocabulary to properly communicate my ideas. I would love to improve this question - any help here is appreciated!