This week I was mainly doing some testing for the code I implemented the previous week. I created JUnit tests for the arrays plugin, dimension, and index classes. I created tests for the methods I implemented and one that creates a file, save to disk, and the read the file to make sure everything was saved. From the test cases, I found some problems with my code. Namely,
- Should I enforce that the model is always valid? At the current moment no. Users can create models that violate the specs (e.g. can create array dimension 3). This is something validation should ensure. This is something I would like to do this summer. However, there are some cases where we want to make sure the user does not do something bad such as use the same id for two or more elements. If you use the same id 'x' for multiple objects and wanted to delete 'x,' which one of them are you referring to?
- Ids for dimension are locally scoped. Previously, I didn't allow the same id to be used multiple times for dimension objects. However, we want the id for dimensions to be locally scooped, meaning SBase 'x' can have a dimension with id 'i' and SBase 'y' can also have a dimension with 'i.' To account for this issue, I had to use the IdManager within JSBML to tell that it is okay to use the same id as long the dimensions are referring to different objects.
- The above condition implies that the Dimension class should not implement UniqueNamedSBase anymore.
- I also had issues with listOf attributes. For instance, when I have a list of CHILD, JSBML would normally refer the attribute to be 'listOfChilds' instead of 'listOfChildren.' I had to do a check in the plugin class for the case of listOf<Index> since the list attribute should be listOfIndices instead of listOfIndexs.
For the following week, I will be looking at the math necessary for the arrays package. That is, look at the JSBML compiler and figure out the steps needed to implement infix parsing. More info to come.