views:

105

answers:

3

Are there any tools out there that let you model how a class (or a class hierarchy) can change at runtime? For example, if I have a given number of mixin classes that will be combined at runtime and I don't know which ones will be combined until the program runs, how do you go about diagramming that type of runtime behavior?

Here's a better example. Let's say that I have a base class called IceCream, and I have over 100 possible flavors that all derive from that one IceCream class. Let's also suppose that any instance of the IceCream class can be combined with another instance of the IceCream class to create a completely unique IceCream type altogether. Given this domain, how do you use a graphical model to actually say that any one of these types can be combined at runtime?

It would be inefficient to model all the possible combinations of IceCream types, given that there can be a virtually infinite number of permuations for these 100 IceCream types. So again, here's the question: Are there any graphical modeling languages that let you specify this sort of behavior?

+1  A: 

Your design sounds a little disturbing. If two different ice creams have different behavior, then why is it wrong to model all the possibilities? Where are you loading the behaviors from? It very well could be the case, but if so I'd guess that you want to contain the behavior instead...

If they don't have different behaviors, then all you are talking is a class "IceCream" with a "Flavor" member. Never create a second class when the only difference is data--the code must actually differ in the two cases to warrant different classes.

If I totally missed something I apologize.

Edit: Let me be more specific about "Containing behavior". If each of your ice-cream flavors had a "Taste" (which is code) and the taste is different between Vanilla, Strawberry and Chocolate--then you have 3 "Taste" ice-cream classes that are contained in one "Cone" class.

The Cone class would be what I think you are trying to model as "IceCream". Since the cone contains all three, a "Lick" method can combine those three in any way possible. Either you can lick(bottom), lick(middle) or lick(top), or you can just lick() and allow the lick method to combine all three into a single call (to be more real-code, you might pass a single variable to lick() that would be forwarded to all contained flavors).

Bill K
Your solution might solve this one particular model, but that's not what I'm looking for here--I'm looking for a modeling language that will let me model the semantics of a dynamic language as it changes itself at runtime. It's not a question about a specific design per se--it's about being able to graph out the changes to the model at runtime.
plaureano
I agree. it's an excellent question. I think the problem is that it's extremely difficult to come up with a good way to do what you are saying, and because of that I tend to shy away from meta-programming as much as possible (Hence my solution).I like to isolate it as much as possible--box it off into a small area that is easier to conceptualize; for problems like the one you suggested, I suggest just designing it in such a way that it doesn't require meta programming. You've pointed out the fundamental flaw--it's a bitch to architect or convey your meta-based design to others.
Bill K
A: 

I wonder if the personal db approach of Bento or DabbleDB could be relevant for the actual modelling part. Then maybe the Django admin's model introspection for the logic part. Sounds like you want to create an interface to a scripting language. A kind of vpl library. So, a beefed up and more reflective Django admin might be a starting point.

hartificial
A: 

In general, if you want to create UML class diagrams you can exploit Generic Types in UML. Also, there is the concept of Template Parameters in UML.

Have a look at this site: Defining Generics with UML Templates

They use the Eclipse Modeling Framework as a tool.

duddle