Sunday, March 25, 2007

Three hats

Refactoring, Functionality, and UI?
 Last time, I distinguished between the hats that a developer wears (one for adding functionality, and another for refactoring). There's a third, in this case, which is UI work. My first goal for today is in this third case - cleaning up the UI so it's more clear how many, and which tests are passing.
 In addition to listing all of the test results, I'll add a summary section with little green/red boxes, each linking to that test result, with mouse over text of the name of the test (and the result). To accomplish this, I will be doing a bit of refactoring, putting all of the results in an array to be displayed later.

UI - Done
 Ok, this enhancement is complete, although I did see some good areas for future refactoring (such as many copy/pasted calls to RunGenericTest function). But all my tests are passing now (and the UI work will really shine once I get more than 25 additional tests), so it's time to put on my functionality hat.

Functionality
 I have distressingly little on my Functionality todo list. I'm worried that I don't know where this program is headed. Well, let's forge ahead - I want to make a canonical list of Abilities, just as there is a list of statistics. I should be able to copy, paste, and go from there.
 Beatles Revolver has finished playing - started Clapton's From the Cradle.

Refactoring again
 Ah I see the problem, I mix calling/storing Statistic by name and by ID. I'd better clear up the confusion before copying statistics to Abilities, or I'll have to fix it in multiple places.
 Ok, I've added StatisticID to the Statistic class (with the idea of replacing the Name member, to force all comparisons to be done by ID). The Name should only be retrieved for display purposes, and should only be known by the CanonicalStatistics object. Run tests - they pass.
 Now to remove the Name member from the Statistic class. Two missed references, fixed, run tests- they pass.

Copying
 Okay, now I'm relatively happy with the Statistics Class. Time to copy & rename. Done. Added SuccessThreshold. Now, I need to remove the references to Ability.Name (for the same reasons I removed references to Statistic.Name). I'll also need to add a CanonicalAbilities class to the global arrParameters.
 Make changes, Run tests - I suppose it would help if I instantiated the object when the Character class is created (:
 Interesting - that turned out to be easier than expected, as no tests required any changes.
 
Relationship between abilities and Statistics
 It's clear to me that an instance of an ability (e.g. this character's success threshold for reading books) may differ from one character to the next. Especially as the characters gain levels. It's not clear to me, however, if the statistic that an ability relies on (such as Reading Books relies on Intelligence and Lift Heavy Object relies on Strength) can vary from character to character. Could a wizard lift heavy objects based on Intelligence, or a fighter read books by strength? While it's tempting (and slightly amusing) to consider these fringe cases, I believe it would severely impact the intuitiveness of the game.
 Thus, the canonical list of abilities should include more than just the name of the ability, but also the ID of the relevant statistic. This is my next goal.
 So, should CCanonicalAbilities have a local copy of CCanonicalStatistics? I think so. Does this mean that the CCharacter class should use the CCanonicalAbilities's copy of CCanonicalStatistics instead of its own? That, I'm not so sure of. For now, no. The CCharacter will include two copies of the object, one for itself, and one its copy of CCanonicalAbilities.
 
Patience, please...
 I'm fighting with arrays. I've just a moment to update you on my progress, as Interdev has decided to unexpected quit. Phew, finally found the error (programmer error, of course, trying to use a zero-based index when a 1-based index is more appropriate).
 Ok, now I can make CanonicalAbilities include both name and relevant statistic. But I've run out of music. I'll be right back.
 Dinner in 5 minutes - let's see if I can whip this together. Whoops! All tests failed! Oh I need to create the CCanonicalStatistics before trying to add Abilities. Ok, all tests pass now.
 Next time I need to add some functional tests. But for now, it's time for lamb chops. See you next time.

0 Comments:

Post a Comment

<< Home