Say I have a Ninja with certain configurable skills. By configurable, I mean the program reads in a configuration file and adds them in at runtime. ie:
Ninja: color: Red Skills: - High Jump - Invisibility
Now, assume these skills need to dynamically add functionality to the Ninja class. As in, if we configure Ninja to have a High Jump skill, then the class needs to follow the CanHighJump Interface, with public void highJump() as a method.
Now there are two ways I can think of to go about this. My first reaction would be to have a Ninja class with String color and then use Reflection to add in the functionality. However, now I realize I could do it through a relational database as well. Have a Ninja class with String color, and forget about any objects relating Ninjas with Skills - instead, whenever I need to check for a skill, just make a call to the database retrieving the possible skills that class can use. Those are the only two truly dynamic solutions I can come up with, and I can't comprehend the design pros/cons of each. I have a feeling the database solution would be far more scale-able, but the reflection method would make most sense to me when coding. No need to guess which skills a Ninja has, because I could easily check for the interface.
I'm hoping someone can give me a bit of insight over a standard design solution for this problem. Whether it be one of the two I came up with, or more likely something i didn't think of.
Thank you,
Phil