Hello everybody,
I'm getting closer to fully implementing a JTree to represent a collection of Series. The hierarchy is Show > Season > Episode.
These are all classes and each one of them implements the MutableTreeNode interface. When starting this project I didn't know that I was going to need this interface, so I defined methods like 'removeFromSeason' in Episode, 'add(Episode ep)' in Season,..
Now that I'm implementing this MutableTreeNode interface I see that many methods overlap. So I'm wondering how I should handle this. For example: the add(Episode ep) in just takes an Episode as argument, while the 'insert(MutableTreeNode child, int index)' uses 2 arguments, the child and the index. In the add episode I just added the episode to the ArrayList at a random position. Each Episodes has a variable containing the number of the Episode so that wasn't a problem.
If I fully replace the add Method, I should also be giving the index of the Episode, which could complicate the ArrayList. Or I would be doing double work, passing the episode and the episode.getNumber() as arguments, which seems stupid to me.
I could also keep both the original methods and the new ones, and let the one call the other. This would doesn't really seem right to me.
What are your opinions on how to handle this? Any comment is appreciated :)
Harm